Hacker News new | ask | show | jobs
by finnyspade 3718 days 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;

}