About the Ergonomics of Applicative JSON Decoding

I think one reason why NoRedInk/elm-json-decode-pipeline feels like magic is the fact that the application operators seem go in the wrong direction when you first look at it. When you create a user without decoders, the application operator points to the left:

User
    <| email
    <| name

But when you build a user within a decoder, it points to the right:

Decode.succeed User
    |> required "email" Decode.string
    |> requiredAt [ "profile", "name" ] Decode.string

Explain that to a newcomer :grin:

But if you use the |= operator, you can just say “it’s like the <| operator, but the arguments are wrapped in a decoder”:

Decode.succeed User
    |= Decode.field "email" Decode.string
    |= Decode.at [ "profile", "name" ] Decode.string
1 Like