Skip to content

Instantly share code, notes, and snippets.

@choonkending
Last active June 4, 2017 11:23
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 choonkending/99d1f761384a905f6ab8799bcda2662a to your computer and use it in GitHub Desktop.
Save choonkending/99d1f761384a905f6ab8799bcda2662a to your computer and use it in GitHub Desktop.
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