Skip to content

modify

modify<S>(f): State<S, undefined>

Defined in: Core/State.ts:85

Applies a function to the current state to produce the next state. Produces no meaningful value.

S

(s) => S

State<S, undefined>

const push = (item: string): State<string[], undefined> =>
  State.modify(stack => [...stack, item]);

State.run(["a"])(push("b")); // [undefined, ["a", "b"]]