Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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