import { fn } from "https://deno.land/x/fun@v2.0.0-alpha.6/mod.ts";
const { chain } = fn;
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.
Examples
Example 1
Example 1
import { pipe, chain } from "./fn.ts";
const add = (n: number) => (m: number) => n + m;
const chainer = pipe(
(n: number) => n,
chain(add),
chain(add),
chain(add),
chain(add),
chain(add),
);
const result1 = chainer(1); // 6
const result2 = chainer(2); // 12
const result3 = chainer(3); // 18