import { apply } from "https://deno.land/x/fun@v2.0.0/state.ts";
Apply the A value of State<E, A> to the (a: A) => I value of State<E, (a: A) => I>, producing a State<E, I>.
Examples
Example 1
Example 1
import * as S from "./state.ts";
import { pipe } from "./fn.ts";
const work = pipe(
S.id<string>(),
S.map(s => (n: number) => s.repeat(n)),
S.apply(S.gets(s => s.length))
);
const result1 = work("Hi"); // ["HiHi", "Hi"]
const result2 = work("Hello");
// ["HelloHelloHelloHelloHello", "Hello"]