map2
Maybe.map2
Some common metaphors for Elm's Universal Pattern (Applicative Pattern).
Mapping
Combining
Lifting
Wrapping and unwrapping boxes
Blog post on Two ways of looking at map functions
Separate branching code from doing code (discussed in-depth in Joël's blog post Problem Solving with Maybe)
Stay at one level of abstraction
Json decoders as combining functions
Scott Wlaschin Railway Oriented Programming
Dillon's blog post Combinators - Inverting Top-Down Transforms
The JSON structure and Elm type don't have to mirror each other - start with your ideal type and work backwards
Applicative pattern
Applicative needs 1) way to construct, 2) map2
or andMap
Json.Decode.Pipeline.required
function
map2
doesn't take a type, it takes a function -NoRedInk/elm-json-decode-pipeline
is a useful reference for implementing this kind of api on your ownelm/parser
episodeSome more blog posts by Joël that related to Elm's Universal Pattern:
Joël's journey to building a parser combinator: