-
-
Save zwilias/7ef0192cb1152a60cd0878bbcd5c60f3 to your computer and use it in GitHub Desktop.
This file contains 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
decoder : Decoder Tree | |
decoder = | |
oneOf | |
[ 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