Skip to main content
Module

x/fun/mod.ts>fn_either.flatmap

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

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>