5 ms·
Wouldn't it be (with a little runtime typechecking): function IdentityMonad(v) { this._v = v; } IdentityMonad.prototype.bind = function(f) { var o =
by finnyspade 10y ago
Wouldn't it be (with a little runtime typechecking):
function IdentityMonad(v) {
this._v = v;
}
IdentityMonad.prototype.bind = function(f) {
var o = f(this._v);
if(!(o instanceof IdentityMonad)){
throw new Error("function must return IdentityMonad");
}
return o;
}