function Monad(modifier) {
return function unit(value) {
var monad = Object.create(null);
monad.bind = function (func) {
return func(value);
}
return monad;
}
}
var idnt = Monad();
var monad = idnt('test');
monad.bind(console.log);
function Monad(modifier) {
var prototype = Object.create(null);
function unit(value) {
var monad = Object.create(prototype);
monad.bind = function (func, args) {
return func(value, ...args);
}
if (typeof modifier == 'function') {
modifier(monad, value);
}
return monad;
}
return unit;
}
var maybe = Monad(function (monad, value) {
if (value === null || value === undefined) {
monad.is_null = true;
monad.bind = function () {
return monad;
}
}
}
var monad = maybe(null);
monad.bind(console.log);