Skip to content

Instantly share code, notes, and snippets.

@pazworld
Created January 13, 2013 12:38
Show Gist options
  • Save pazworld/4523875 to your computer and use it in GitHub Desktop.
Save pazworld/4523875 to your computer and use it in GitHub Desktop.
Maybe monad written in JavaScript.
// Maybe monad.
var Maybe = {
Just: function(a) {
this.value = a;
this.bind = function(f) { return f(this.value); };
},
None: function() {
this.bind = function() { return this; };
},
return: function(a) { return new Maybe.Just(a); }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment