import { fn_either } from "https://deno.land/x/fun@v2.0.0-alpha.6/mod.ts";
const { bimap } = fn_either;
Map over the left and right return values of a FnEither.
Examples
Example 1
Example 1
import * as FE from "./fn_either.ts";
import * as E from "./either.ts";
import { pipe } from "./fn.ts";
const boundedValue = (n: number) => n > 10 || n < 0 ? E.left(n) : E.right(n);
const log = pipe(
boundedValue,
FE.bimap(n => `Out of bounds: ${n}`, n => `Received a good value: ${n}`),
);
const result1 = log(1); // Right("Received a good value: 1")
const result2 = log(20); // Left("Out of bounds: 20")