Create a gist now

Instantly share code, notes, and snippets.

@zwilias /final.elm Secret
Created Aug 2, 2017

decoder : Decoder Tree
decoder =
[ lazy (\_ -> branchDecoder)
, leafDecoder
branchDecoder : Decoder Tree
branchDecoder =
map2 Branch
(field "name" string)
(field "children" (list <| lazy (\_ -> decoder)))
leafDecoder : Decoder Tree
leafDecoder =
map2 Leaf
(field "name" string)
(field "value" int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment