Skip to content

Instantly share code, notes, and snippets.

@zwilias
Created August 2, 2017 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zwilias/b276cf935f463322ae5cac1374a25cbf to your computer and use it in GitHub Desktop.
Save zwilias/b276cf935f463322ae5cac1374a25cbf to your computer and use it in GitHub Desktop.
decoder : Decoder Tree
decoder =
oneOf
[ lazy (\_ -> 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