@jsoldi/hkt
Version:
Higher kinded types for typescript and a few utility monads.
20 lines • 605 B
JavaScript
import { monad } from "./monad.js";
import { id, pipe } from "../core/utils.js";
const is_monadTrans = Symbol("is_monadTrans");
/** Creates a monad that can transform another monad from an `IMonadTransBase`. */
export function monadTrans(base) {
if (is_monadTrans in base)
return base;
return pipe(base, base => ({
...monad(base),
...base
}), base => {
const flatten = (fa) => base.bind(base.lift(fa), id);
return {
[]: true,
flatten,
...base,
};
});
}
//# sourceMappingURL=transformer.js.map