UserRecordDecoder =
D.map2 UserRecord
(D.field "id" D.int)
(D.field "level" D.int)
type alias UserRecord =
{ id : Int
, level : Int
}
will do the job however if we inverse the order of the fields like this
type alias UserRecord =
{ level : Int
, id : Int
}
for a user { id = 1, level = 10 } you will get { id = 10, level = 1 }
Would it be better and possible not to assert that the orders of decoder and record match when decoding json and decode just according to the field names?
I started to use it, documentation is great, thanks to have spent time on it!
With elm-format the nested scopes show up !
And I got a better understanding of the do notation (Decode.succeed == return ), I love functional ~