Noah posted an alternate syntax for JSON decoders that could make use of a
better record update syntax.
(post:
https://medium.com/@eeue56/json-decoding-in-elm-is-still-difficult-cad2d1fb39ae#.ia6brcxw5)
In short, he suggests decoupling the decoder order from the record order
using the following API:
decodeModel : Json.Value -> Result String Model
decodeModel value =
Ok { name = "", age = 0 }
|> decodeField "age" Json.int <http://json.int/> setAge value
|> decodeField "name" Json.string setName value
Where setName and setAge have to be defined as such:
setName : Model -> String -> Model
setName model name =
{ model | name = name }
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.