var _Maybe = function(val) {
this.val = val;
}
var map = function(f, obj) {
return obj.map(f);
}
var Maybe = function(x) {
return new _Maybe(x);
}
_Maybe.prototype.map = function(f) {
return this.val ? Maybe(f(value)) : Maybe(null)
}
var endResult = Maybe(null).map(function(s) {
return someFunction(s)
});
console.log(endResult);
Last active
October 1, 2016 04:37
-
-
Save RyanCCollins/9afc16b9170053e42b1bd723680ba205 to your computer and use it in GitHub Desktop.
Maybe and other functors JavaScript
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment