Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/mod.ts>async_either.recover

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function async_either.recover
import { async_either } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { recover } = async_either;

Chain AsyncEither based failures, Left sides, useful for recovering from error conditions.

import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
import * as TE from "./async_either.ts";
import * as E from "./either.ts";
import { pipe } from "./fn.ts";

const ta = pipe(
  TE.fail(1),
  TE.recover(n => TE.wrap(n*2)),
  TE.flatmap(n => TE.wrap(n**2))
)

assertEquals(await ta(), E.right(4))

Parameters

fbtj: (b: B) => AsyncEither<J, I>

Returns

<A>(ta: AsyncEither<B, A>) => AsyncEither<J, A | I>