Skip to content

Instantly share code, notes, and snippets.

@mattfield
Last active December 20, 2015 05:29
Show Gist options
  • Save mattfield/6078866 to your computer and use it in GitHub Desktop.
Save mattfield/6078866 to your computer and use it in GitHub Desktop.
Maybe functor
var Maybe = function(val){
this.val = val;
};
Maybe.prototype.map = function(f){
return this.val ? Maybe(f(this.val)) : Maybe(null);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment