Skip to content

Instantly share code, notes, and snippets.

@SimonRichardson
Created August 1, 2013 16:11
Show Gist options
  • Select an option

  • Save SimonRichardson/6132841 to your computer and use it in GitHub Desktop.

Select an option

Save SimonRichardson/6132841 to your computer and use it in GitHub Desktop.
Idea behind adding GADT to squishy-pants, it's not a nice as other languages, but this is the best we can do currently in a dynamic world.
var a = _.List(_.Some(_.Right(1)), _.Some(_.Left('Error')));
var result = a.match({
Some: {
Right: partial(
function(a) {
return a == 1;
},
_.identity
),
Right: _.constant(-1),
_: _.constant(-1)
},
None: _.constant(-1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment