You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We currently have examples in tests where we use <|> from Result or Option to essentially fall through multiple decoders until we find one that works. This isn't ideal because it requires you to run each decoder, even if the first one succeeds.
Arguably, Decode.oneOf already solves this use case, but in the spirit of making decoders more composable (#23), we could add Decode.alt that looks something like this:
Since you'd be applying alt to the decode functions themselves (instead of the output option/result), we should be able to only run subsequent decoders if we haven't yet found a successful value
We can probably rewrite oneOf to use this alt function?
TriedMultiple is still coming, and I haven't yet written tests to prove that the alt implementation is lazy (it definitely is). Other than that, this is done.
We currently have examples in tests where we use
<|>
from Result or Option to essentially fall through multiple decoders until we find one that works. This isn't ideal because it requires you to run each decoder, even if the first one succeeds.Arguably,
Decode.oneOf
already solves this use case, but in the spirit of making decoders more composable (#23), we could addDecode.alt
that looks something like this:alt
to the decode functions themselves (instead of the output option/result), we should be able to only run subsequent decoders if we haven't yet found a successful valueoneOf
to use thisalt
function?TriedMultiple
error to track the failure from each decoder that has been attempted (Add a new ParseError constructor "TriedMultiple" #26)The text was updated successfully, but these errors were encountered: