Skip to content

map

map<S, A, B>(f): (st) => State<S, B>

Defined in: Core/State.ts:101

Transforms the value produced by a State computation. The state transformation is unchanged.

S

A

B

(a) => B

(st): State<S, B>

State<S, A>

State<S, B>

const readLength: State<string[], number> = pipe(
  State.get<string[]>(),
  State.map(stack => stack.length),
);

State.run(["a", "b", "c"])(readLength); // [3, ["a", "b", "c"]]