flatmap
import { flatmap } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/fn.ts";Create a new Fn by combining A => L => I with D => A to produce D & L => I. This is equivalent to ap with the first two arguments switched. It is also limited to unary functions in order to properly handle type widening on the input type.
@example
import { pipe, flatmap } from "./fn.ts";
const add = (n: number) => (m: number) => n + m;
const flatmaper = pipe(
(n: number) => n,
flatmap(add),
flatmap(add),
flatmap(add),
flatmap(add),
flatmap(add),
);
const result1 = flatmaper(1); // 6
const result2 = flatmaper(2); // 12
const result3 = flatmaper(3); // 18