A lifted function which maps from Cat<T>
to Cat<U>
.
import { Cat, cat, flatMap } from "./cat.ts";
import { assertEquals } from "../deps.ts";
const sub = (num: number): Cat<string> =>
cat(num).feed((x) => x.toString());
const actual = flatMap(sub)(cat(6)).value;
assertEquals(actual, "6");
Generated using TypeDoc
Maps an inner value of
Cat
into anotherCat
by applying a function. It is useful to lift a subroutine withCat
.