Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

flatmap

import { flatmap } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/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>.

@example
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]
function flatmap<A, E, I>(fati: (a: A) => State<E, I>): (ta: State<E, A>) => State<E, I>;
§
flatmap<A, E, I>(fati: (a: A) => State<E, I>): (ta: State<E, A>) => State<E, I>
[src]

§Type Parameters

§Parameters

§
fati: (a: A) => State<E, I>
[src]

§Return Type

§
(ta: State<E, A>) => State<E, I>
[src]