Skip to content

Instantly share code, notes, and snippets.

@mattfield
Created September 16, 2013 09:36
Show Gist options
  • Save mattfield/6578528 to your computer and use it in GitHub Desktop.
Save mattfield/6578528 to your computer and use it in GitHub Desktop.
Either functor
var Either = function(left, right){
this.left = left;
this.right = right;
};
Either.prototype.map = function(f){
return this.right ?
Either(this.left, f(this.right)) :
Either(f(this.left), this.left);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment