import { flatmap } from "https://deno.land/x/fun@v2.0.0/state.ts";
Pass the A value in a State<S, A> into a function (a: A) => State<S, I>. This results in a new State<S, I>.
Examples
Example 1
Example 1
import * as S from "./state.ts";
import { pipe } from "./fn.ts";
const state = pipe(
S.id<number>(),
S.flatmap(n => S.wrap(n + 1)),
);
const result1 = state(1); // [2, 1]
const result2 = state(2); // [3, 2]