Today I found my team struggling over decoding some fixed-structure JSON. Search this list for "decode" to see further examples.
Even though I understand decoders well enough to use them, I still don't want to use them. For one thing, I don't deal with fuzzy JSON. I have type aliases that match the JSON structures. Decoder code is entirely redundant with the information in the type alias. Secondly, writing a decoder is demonstrably beginner unfriendly. (Read the search results or watch a beginner struggle with it to see for yourself.) So writing a decoder is painful both conceptually and because it's redundant work. In the shorter term, my prevailing alternative to decoding in 0.17 is just to use ports to launder the JSON into clean Elm types, since ports are automatically decoded. But notably Date will not pass through ports. Not a frequent need for me but if I did need a Date type, another type alias with date as string or int would be required. Then that would have to be converted to the real record. It's even more redundant work (albeit simpler), so I'll avoid if possible. In the longer term, the solution that jumps out at me is the compiler could generate decoders for marked type aliases automatically. (I assume ports work this way already.) And decoding is still there for fuzzy scenarios. Anyway, I saw in one of the Elm-conf videos Evan say that if I have issues, I should say something. So there it is. The other main issue we have looks to get fixed next version (changes to files not being recompiled). -- 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.
