Skip to content

Instantly share code, notes, and snippets.

@zwilias
Created April 1, 2017 14:11
Show Gist options
  • Save zwilias/de1e422e2d3a10f00b89a466c179d9d7 to your computer and use it in GitHub Desktop.
Save zwilias/de1e422e2d3a10f00b89a466c179d9d7 to your computer and use it in GitHub Desktop.
nodeDecoder : Decoder Node
nodeDecoder =
oneOf
[ intNodeDecoder
, stringNodeDecoder
]
intNodeDecoder : Decoder Node
intNodeDecoder =
map2 IntNode
(field "val" int)
(field "children" (list (lazy (\_ -> nodeDecoder))))
stringNodeDecoder : Decoder Node
stringNodeDecoder =
map2 StringNode
(field "val" string)
(field "children" (list (lazy (\_ -> nodeDecoder))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment