Created
August 1, 2013 16:11
-
-
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.
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
| 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