Hi everyone, I would like to write a customizable frontend where different roles in an organization see different widgets on their dashboard. The mapping for which widgets belong to which roles are stored in the server/database where they can be configured/enabled/disabled based on admin controls and the like.
To make the final dashboard, I will return some kind of template language that looks a lot like Elm's definition of Html with names of components that map to some components/view functions I've written in Elm: type Template = Body String | Tag String (List (String, String)) (List Template) makeHtml : Template -> Html Msg -- (i've written this function already) Now, I'd like to write a decoder that can take Json Object that looks like the template object and converts it into the template object. Something like : ("tag", {"attr": "value"}, ["string body", ("tag2", {}, [])]) -> Tag "tag" [("attr", "value")] [Body "string body", Tag "tag2" [] []] There are no tuples in Json, so instead I decided to go with an object: {"tag" : "tag", "attrs" : {"attr" : "value"}, "body" : ["string body", {"tag" : "tag2", "attrs": {}, body: []}]} Now I need to parse this object into the Template type. In general, I'm interested in seeing what decoders look like for recursive types, like List, BinaryTree, RoseTree, and so on. What's the standard way to write them? I'm also not sure how to decode a union type like this one. -- 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 elm-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.