flatmap
import { flatmap } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/either.ts";Chain computations by applying a function that returns an Either to the Right value of an Either. Left values are unchanged.
@example
import * as E from "./either.ts";
const divide = (a: number) => (b: number) =>
b === 0 ? E.left("Division by zero") : E.right(a / b);
const result1 = E.flatmap(divide(10))(E.right(2));
// Right(5)
const result2 = E.flatmap(divide(10))(E.right(0));
// Left("Division by zero")
const result3 = E.flatmap(divide(10))(E.left("Invalid input"));
// Left("Invalid input")