import * as E from "../../Either"; import { pipe } from "../../Function"; import { bimapEither } from "./bifunctor"; import type { XRef } from "./model"; /** * Transforms the `set` value of the `XRef` with the specified fallible * function. */ export const contramapEither = (f: (_: C) => E.Either) => ( _: XRef ): XRef => pipe( _, bimapEither(f, (x) => E.right(x)) ); /** * Transforms the `set` value of the `XRef` with the specified fallible * function. */ export const contramapEither_ = ( _: XRef, f: (_: C) => E.Either ): XRef => contramapEither(f)(_); /** * Transforms the `set` value of the `XRef` with the specified function. */ export const contramap: (f: (_: C) => A) => (_: XRef) => XRef = (f) => contramapEither((c) => E.right(f(c))); /** * Transforms the `set` value of the `XRef` with the specified function. */ export const contramap_: (_: XRef, f: (_: C) => A) => XRef = (_, f) => contramap(f)(_);