import * as E from "../Either"; import { succeed } from "./constructors"; import { foldM_ } from "./fold"; import type { XPure } from "./model"; import { chain_ } from "./monad"; /* * ------------------------------------------- * Fallible XPure * ------------------------------------------- */ export const recover = (fa: XPure): XPure> => foldM_( fa, (e) => succeed(E.left(e)), (a) => succeed(E.right(a)) ); export const absolve = (fa: XPure>): XPure => chain_(fa, E.fold(fail, succeed));