Last active
June 4, 2017 11:23
-
-
Save choonkending/99d1f761384a905f6ab8799bcda2662a 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
const Option = x => (x === undefined || x === null) ? None : Some(x); | |
const Some = x => ({ | |
map: f => Some(f(x)), | |
flatMap: f => f(x), | |
fold: (ifEmpty, f) => f(x) | |
}); | |
const None = { | |
map: f => None, | |
flatMap: f => None, | |
fold: (ifEmpty, f) => ifEmpty() | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment