Name: Anonymous 2011-04-05 17:49
x >>= f >>= g >>= his
h(do_monad_magic(g(do_monad_magic(f(do_monad_magic(x))))))
x >>= f >>= g >>= hh(do_monad_magic(g(do_monad_magic(f(do_monad_magic(x))))))
function Monad(bind, unit) {
this.bind = bind;
this.unit = unit;
}
Identity =
new Monad(function(x, f) { return f(x); },
function(x) { return x; });
List =
new Monad(function(x, f) {
var y = x.map(f);
return Array.prototype.concat.apply(y);
}, function (x) { return [x]; });