the difference between validation and parsing lies almost entirely in how information is preserved
Shotgun parsing is a programming antipattern whereby parsing and input-validating code is mixed with and spread across processing code—throwing a cloud of checks at the input, and hoping, without any systematic justification, that one or another would catch all the “bad” cases.
a parser is just a function that consumes less-structured input and produces more-structured output [...] some values in the domain do not correspond to any value in the range—so all parsers must have some notion of failure
Maybe.withDefault
might indicate an opportunity to parseTwo ways to use this technique:
Weaken return type
Strengthen input type
Elm Radio JSON decoders episode