← Back

Source

state

Monad2<URI>

Added in v1.0.0 (instance)

State

constructor(readonly run: (s: S) => [A, S]) {}

Added in v1.0.0 (data)

ap

<B>(fab: State<S, (a: A) => B>): State<S, B>

Added in v1.0.0 (method)

ap_

<B, C>(this: State<S, (b: B) => C>, fb: State<S, B>): State<S, C>

Added in v1.0.0 (method)

Flipped version of ap

applyFirst

<B>(fb: State<S, B>): State<S, A>

Added in v1.7.0 (method)

Combine two effectful actions, keeping only the result of the first

applySecond

<B>(fb: State<S, B>): State<S, B>

Added in v1.7.0 (method)

Combine two effectful actions, keeping only the result of the second

chain

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

Added in v1.0.0 (method)

eval

(s: S): A

Added in v1.0.0 (method)

exec

(s: S): S

Added in v1.0.0 (method)

map

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

Added in v1.0.0 (method)

get

<S>(): State<S, S>

Added in v1.0.0 (function)

Get the current state

gets

<S, A>(f: (s: S) => A): State<S, A>

Added in v1.0.0 (function)

Get a value which depends on the current state

modify

<S>(f: (s: S) => S): State<S, undefined>

Added in v1.0.0 (function)

Modify the state by applying a function to the current state

put

<S>(s: S): State<S, void>

Added in v1.0.0 (function)

Set the state