Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
decoder : Decoder Tree
decoder =
oneOf
[ branchDecoder
, leafDecoder
]
branchDecoder : Decoder Tree
branchDecoder =
map2 Branch
(field "name" string)
(field "children" (list 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