Comment

Comment by finnyspade

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;

}
parent finnyspade 10 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton