Safe Haskell | Safe-Inferred |
---|

Access helper functions in the State monad class

- set :: MonadState r m => T r a -> a -> m ()
- get :: MonadState r m => T r a -> m a
- modify :: MonadState r m => T r a -> (a -> a) -> m ()
- getAndModify :: MonadState r m => T r a -> (a -> a) -> m a
- modifyAndGet :: MonadState r m => T r a -> (a -> a) -> m a
- (%=) :: MonadState r m => T r a -> a -> m ()
- (%:) :: MonadState r m => T r a -> (a -> a) -> m ()
- lift :: MonadState r mr => T r s -> State s a -> mr a
- liftT :: (Monad m, MonadTrans t, MonadState r (t m)) => T r s -> StateT s m a -> t m a

# accessors in the form of actions in the state monad

set :: MonadState r m => T r a -> a -> m ()Source

get :: MonadState r m => T r a -> m aSource

modify :: MonadState r m => T r a -> (a -> a) -> m ()Source

getAndModify :: MonadState r m => T r a -> (a -> a) -> m aSource

Modify a record element and return its old value.

modifyAndGet :: MonadState r m => T r a -> (a -> a) -> m aSource

Modify a record element and return its new value.

(%=) :: MonadState r m => T r a -> a -> m ()Source

Infix variant of `set`

.

(%:) :: MonadState r m => T r a -> (a -> a) -> m ()Source

Infix variant of `modify`

.

# lift a state monadic accessor to an accessor of a parent record

lift :: MonadState r mr => T r s -> State s a -> mr aSource

liftT :: (Monad m, MonadTrans t, MonadState r (t m)) => T r s -> StateT s m a -> t m aSource