Skip to content

run

run<S>(initialState): <A>(st) => readonly [A, S]

Defined in: Core/State.ts:188

Runs a State computation with an initial state, returning both the produced value and the final state as a pair.

Data-last — the computation is the data being piped.

S

S

<A>(st): readonly [A, S]

A

State<S, A>

readonly [A, S]

const program = pipe(
  State.modify<number>(n => n + 1),
  State.chain(() => State.get<number>()),
);

State.run(0)(program); // [1, 1]