Module

Uncurried.State

Package
purescript-uncurried-transformers
Repository
PureFunctor/purescript-uncurried-transformers

This module defines the State monad.

#State Source

type State s = StateT s Identity

A type synonym for a StateT with Identity as its base monad.

#state Source

state :: forall s a. (s -> (a /\ s)) -> State s a

Construct a State given a function that treads through some state.

#runState Source

runState :: forall s a. s -> State s a -> (a /\ s)

Runs a computation inside of State.

#evalState Source

evalState :: forall s a. s -> State s a -> a

Runs a computation inside of State, discarding the final state.

#execState Source

execState :: forall s a. s -> State s a -> s

Runs a computation inside of State, discarding the final result.

#mapState Source

mapState :: forall s a b. ((a /\ s) -> (b /\ s)) -> State s a -> State s b

Modifies the result type of a State.

#withState Source

withState :: forall s a. (s -> s) -> State s a -> State s a

Modifies the state of a State.