import { fn_either } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { compose } = fn_either;
Compose two FnEithers, passing the right value of the first into the second.
Examples
Example 1
Example 1
import * as FE from "./fn_either.ts";
import { pipe } from "./fn.ts";
const isPositive = (n: number) => n > 0;
const isInteger = (n: number) => Number.isInteger(n);
const isPositiveInteger = pipe(
FE.fromPredicate(isPositive),
FE.compose(FE.fromPredicate(isInteger)),
);
const result1 = isPositiveInteger(0); // Left(0)
const result2 = isPositiveInteger(1); // Right(1)
const result3 = isPositiveInteger(1.1); // Left(1.1)