Created
April 1, 2017 14:11
-
-
Save zwilias/de1e422e2d3a10f00b89a466c179d9d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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