Module
Control.Monad.State.Class
- Package
- purescript-transformers
- Repository
- purescript/purescript-transformers
This module defines the MonadState type class and its instances.
#MonadState Source
class (Monad m) <= MonadState s m | m -> s whereThe MonadState s type class represents those monads which support a single piece of mutable
state of type s.
state fupdates the state using the functionf.
An implementation is provided for StateT, and for other monad transformers
defined in this library.
Laws:
do { get ; get } = getdo { put x ; put y } = put ydo { put x ; get } = put x $> xdo { s <- get ; put s } = pure unit
Members
#get Source
get :: forall m s. MonadState s m => m sGet the current state.
#gets Source
gets :: forall s m a. MonadState s m => (s -> a) -> m aGet a value which depends on the current state.
#put Source
put :: forall m s. MonadState s m => s -> m UnitSet the state.
#modify Source
modify :: forall s m. MonadState s m => (s -> s) -> m sModify the state by applying a function to the current state. The returned value is the new state value.
#modify_ Source
modify_ :: forall s m. MonadState s m => (s -> s) -> m Unit- Modules
- Control.
Comonad. Env - Control.
Comonad. Env. Class - Control.
Comonad. Env. Trans - Control.
Comonad. Store - Control.
Comonad. Store. Class - Control.
Comonad. Store. Trans - Control.
Comonad. Traced - Control.
Comonad. Traced. Class - Control.
Comonad. Traced. Trans - Control.
Comonad. Trans. Class - Control.
Monad. Cont - Control.
Monad. Cont. Class - Control.
Monad. Cont. Trans - Control.
Monad. Error. Class - Control.
Monad. Except - Control.
Monad. Except. Trans - Control.
Monad. Identity. Trans - Control.
Monad. List. Trans - Control.
Monad. Maybe. Trans - Control.
Monad. RWS - Control.
Monad. RWS. Trans - Control.
Monad. Reader - Control.
Monad. Reader. Class - Control.
Monad. Reader. Trans - Control.
Monad. State - Control.
Monad. State. Class - Control.
Monad. State. Trans - Control.
Monad. Trans. Class - Control.
Monad. Writer - Control.
Monad. Writer. Class - Control.
Monad. Writer. Trans