Closed njlr closed 5 months ago
Hum, this is because Decode.value
does no checks.
It is defined as let value _ v = Ok v
meaning that anything you pass to it succeed. It was added because Elm implementation had it.
So I am unsure what to do here. TBH honest I never used Decode.value
🙈
Looking once again at how Elm implements this I believe the current implementation of Decode.value
is correct in the legacy package.
Because, I don't know in which case Decode.value
should be used, I am going to remove it from the new API.
It implementation would looks like this:
let value<'a> =
{ new Decoder<'a> with
member _.Decode(_, value) = Ok (unbox value)
}
let succeed (output: 'a) : Decoder<'a> =
{ new Decoder<'a> with
member _.Decode(_, _) = Ok output
}
Which feels really strange to me and I believe the goal of Decode.value
in Elm lang, is to work around some interop things if needed. If someone, is using it please feel free to open an issue with the use case so we can check if we should support it or if there are others API to archive te same things.
@njlr If you want me to look into your use case, please feel free to provide a example with an explanation of what you are trying to archive.
Decode.fromString Decode.value ""
returnsOk null
instead of an error.Issue is demonstrated by this script: