data-accessor-mtl-0.2.0.5: Use Accessor to access state in mtl State monad class

Safe Haskell | Safe-Inferred
Language | Haskell98

Data.Accessor.Monad.MTL.State

Contents

- accessors in the form of actions in the state monad
- lift a state monadic accessor to an accessor of a parent record

Description

Access helper functions in the State monad class

Synopsis

- 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 :: forall (m :: Type -> Type) t r s a. (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 a Source #

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

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

Modify a record element and return its old value.

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

Modify a record element and return its new value.

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

Infix variant of `set`.

(%:) :: MonadState r m => T r a -> (a -> a) -> m () infix 1 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 a Source #

liftT :: forall (m :: Type -> Type) t r s a. (Monad m, MonadTrans t, MonadState r (t m)) => T r s -> StateT s m a -> t m a Source #