lux/codata/state

Types

State

Stateful computations.

(type: (State s a)
  (-> s [s a]))

State'

Stateful computations decorated by a monad.

(type: (State' M s a)
  (-> s (M [s a])))

Structs

Applicative<State>

(All [a] (lux/control/applicative;Applicative (State a)))

Functor<State>

(All [a] (lux/control/functor;Functor (State a)))

Monad<State>

(All [a] (lux/control/monad;Monad (State a)))

(StateT Monad<M>)

A monad transformer to create composite stateful computations.

(All [a b] (-> (lux/control/monad;Monad a) (lux/control/monad;Monad (State' a b))))

Values

get

Read the current state.

(All [a] (State a a))

(lift-state Monad<M> ma)

Lift monadic values to the State' wrapper.

(All [a b c] (-> (lux/control/monad;Monad a) (a c) (State' a b c)))

(local change action)

Run computation with a locally-modified state.

(All [a b] (-> (-> a a) (State a b) (State a b)))

(put new-state)

Set the new state.

(All [a] (-> a (State a lux;Unit)))

(run state action)

Run a stateful computation.

(All [a b] (-> a (State a b) [a b]))

(run' state action)

Run a stateful computation decorated by a monad.

(All [a b c] (-> b (State' a b c) (a [b c])))

(update change)

Compute the new state.

(All [a] (-> (-> a a) (State a lux;Unit)))

(use user)

Run function on current state.

(All [a b] (-> (-> a b) (State a b)))