import { pipe } from "../../Function"; import * as T from "../Task/_core"; import { contramapM } from "./contravariant"; import { mapM } from "./functor"; import type { XRefM } from "./model"; /** * Performs the specified effect every time a value is written to this * `XRefM`. */ export const tapInput_ = ( self: XRefM, f: (a: A1) => T.Task ) => pipe( self, contramapM((c: A1) => pipe(f(c), T.as(c))) ); /** * Performs the specified effect every time a value is written to this * `XRefM`. */ export const tapInput = (f: (a: A1) => T.Task) => ( self: XRefM ) => tapInput_(self, f); /** * Performs the specified effect every time a value is written to this * `XRefM`. */ export const tapOutput_ = ( self: XRefM, f: (b: B) => T.Task ) => pipe( self, mapM((b) => pipe(f(b), T.as(b))) ); /** * Performs the specified effect every time a value is written to this * `XRefM`. */ export const tapOutput = (f: (b: B) => T.Task) => ( self: XRefM ) => tapOutput_(self, f);