Create a gist now

Instantly share code, notes, and snippets.

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