Skip to content

Instantly share code, notes, and snippets.

@zwilias
Created August 2, 2017 10:03
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/699cb7053c6a9668687489d946c45c2b to your computer and use it in GitHub Desktop.
Save zwilias/699cb7053c6a9668687489d946c45c2b to your computer and use it in GitHub Desktop.
var leafDecoder = map2(Leaf, field('name', string), field('value', int));
var branchDecoder = map2(
Branch,
field('name', string),
field('children', list(lazy(function (_) { return decoder; })))
);
var decoder = oneOf([
branchDecoder,
leafDecoder
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment