Skip to main content
Module

x/fun/mod.ts>fn_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 fn_either.recover
import { fn_either } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { recover } = fn_either;

Chain the left result of one FnEither into another FnEither.

Examples

Example 1

import * as FE from "./fn_either.ts";
import { pipe } from "./fn.ts";

const result = pipe(
  FE.id<string, number>(),
  FE.flatmap(s => FE.left(s.length)),
  FE.recover(n => FE.right(String(n))),
)("Hello"); // Right("5")

Type Parameters

B
optional
D = unknown
optional
I = never
optional
J = never

Parameters

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

Returns

<A = never>(ua: FnEither<D, B, A>) => FnEither<D, J, A | I>