Table of contents


State (interface)

Signature

export interface State<S, A> {
  (s: S): [A, S]
}

Added in v2.0.0

URI (type alias)

Signature

export type URI = typeof URI

Added in v2.0.0

URI (constant)

Signature

export const URI: "State" = ...

Added in v2.0.0

evalState (constant)

Run a computation in the State monad, discarding the final state

Signature

export const evalState: <S, A>(ma: State<S, A>, s: S) => A = ...

Added in v2.0.0

execState (constant)

Run a computation in the State monad discarding the result

Signature

export const execState: <S, A>(ma: State<S, A>, s: S) => S = ...

Added in v2.0.0

get (constant)

Get the current state

Signature

export const get: <S>() => State<S, S> = ...

Added in v2.0.0

gets (constant)

Get a value which depends on the current state

Signature

export const gets: <S, A>(f: (s: S) => A) => State<S, A> = ...

Added in v2.0.0

modify (constant)

Modify the state by applying a function to the current state

Signature

export const modify: <S>(f: (s: S) => S) => State<S, void> = ...

Added in v2.0.0

of (constant)

Signature

export const of: <S, A>(a: A) => State<S, A> = ...

Added in v2.0.0

put (constant)

Set the state

Signature

export const put: <S>(s: S) => State<S, void> = ...

Added in v2.0.0

state (constant)

Signature

export const state: Monad2<URI> = ...

Added in v2.0.0

ap (export)

Signature

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

Added in v2.0.0

apFirst (export)

Signature

<E, B>(fb: State<E, B>) => <A>(fa: State<E, A>) => State<E, A>

Added in v2.0.0

apSecond (export)

Signature

<E, B>(fb: State<E, B>) => <A>(fa: State<E, A>) => State<E, B>

Added in v2.0.0

chain (export)

Signature

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

Added in v2.0.0

chainFirst (export)

Signature

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

Added in v2.0.0

flatten (export)

Signature

<E, A>(mma: State<E, State<E, A>>) => State<E, A>

Added in v2.0.0

map (export)

Signature

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

Added in v2.0.0