Closed rtfeldman closed 7 years ago
LGTM. Arguably this should be how core/maybe works, but that's down the road.
Well maybe
is more general - it's not specific to decoding objects, and so doesn't take a fieldName
string.
(Having said that, perhaps if this exists there's no longer a reasonable use case for maybe
...)
This is a standalone alternative to
optional
fromelm-decode-pipeline
.It's a field-specific variation on
maybe
, where the only difference is that if the field is present but malformed, decoding fails. (Whereas withmaybe (field "foo" string)
, a field that is present but malformed succeeds withNothing
, meaning you don't find out that you received some malformed json.)