@jsoldi/hkt
Version:
Higher kinded types for typescript and a few utility monads.
15 lines • 671 B
JavaScript
import { monadPlus } from "../../classes/monadPlus.js";
import { either } from "../either.js";
import { contMonad } from "./contMonad.js";
/** The void continuation module, where computations do not return a value. */
export const contVoid = (() => {
return {
...contMonad(monadPlus.void),
sleep: (delay = 0) => resolve => { setTimeout(resolve, delay); },
toPromise: ca => new Promise((resolve, reject) => ca(e => e.right ? resolve(e.value) : reject(e.value))),
fromPromise: pa => resolve => {
pa.then(a => resolve(either.right(a)), e => resolve(either.left(e)));
}
};
})();
//# sourceMappingURL=contVoid.js.map