UNPKG

fp-ts-bracket

Version:
32 lines (31 loc) 856 B
import { fromEitherK, } from "fp-ts/lib/FromEither"; import { flow } from "fp-ts/lib/function"; /** @internal */ export function as(F) { return (self, b) => F.map(self, () => b); } /** @internal */ export function asUnit(F) { const asM = as(F); return (self) => asM(self, undefined); } /** @internal */ export function tap(M) { return (first, f) => M.chain(first, (a) => M.map(f(a), () => a)); } /** @internal */ export function tapEither(F, M) { const fromEither = fromEitherK(F); const tapM = tap(M); return (self, f) => tapM(self, fromEither(f)); } /** @internal */ export function tapIO(F, M) { const chainFirstM = tap(M); return (self, f) => chainFirstM(self, flow(f, F.fromIO)); } /** @internal */ export function tapTask(F, M) { const tapM = tap(M); return (self, f) => tapM(self, flow(f, F.fromTask)); }