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

x/fun/fn_either.ts>flatmap

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

Chain the right 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>(),
  FE.flatmap(s => FE.right(s.length)),
)("Hello"); // Right(5)

Type Parameters

A
optional
L = unknown
optional
J = never
optional
I = never

Parameters

fati: (a: A) => FnEither<L, J, I>

Returns

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