Decode.lazy was what I was looking for, thank you! However, now I have a new problem. Here is the new definitions of the decoders:
type alias Elem = { tag : String, attrs : List ( String, String ), body : List Template } type Template = Body String | Tag Elem decodeTemplate : Json.Decoder Template decodeTemplate = Json.oneOf [ Json.map Tag decodeElem, Json.map Body Json.string ] decodeElem : Json.Decoder Elem decodeElem = Json.map3 Elem (Json.field "tag" Json.string) (Json.field "attrs" (Json.keyValuePairs Json.string)) (Json.field "body" (Json.list (Json.lazy (\_ -> decodeTemplate)))) I got the decoder to compile, but only by using oneOf. Is there a better way to decode ADT's with multiple branches? Am I guaranteed to have the decoders be tried in the order that they are put in the list? -- 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.