Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Deprecated: Use Control.Monad.Trans.MultiState instead
The multi-valued version of mtl's State / StateT / MonadState
- newtype MultiStateT x m a = MultiStateT {
- runMultiStateTRaw :: StateT (HList x) m a
- type MultiStateTNull = MultiStateT '[]
- type MultiState x = MultiStateT x Identity
- class Monad m => MonadMultiState a m where
- runMultiStateT :: Functor m => HList s -> MultiStateT s m a -> m (a, HList s)
- runMultiStateTAS :: Functor m => HList s -> MultiStateT s m a -> m (a, HList s)
- runMultiStateTSA :: Monad m => HList s -> MultiStateT s m a -> m (HList s, a)
- runMultiStateTA :: Monad m => HList s -> MultiStateT s m a -> m a
- runMultiStateTS :: Monad m => HList s -> MultiStateT s m a -> m (HList s)
- runMultiStateT_ :: Functor m => HList s -> MultiStateT s m a -> m ()
- runMultiStateTNil :: Monad m => MultiStateT '[] m a -> m a
- runMultiStateTNil_ :: Functor m => MultiStateT '[] m a -> m ()
- withMultiState :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m (a, s)
- withMultiStateAS :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m (a, s)
- withMultiStateSA :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m (s, a)
- withMultiStateA :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m a
- withMultiStateS :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m s
- withMultiState_ :: (Functor m, Monad m) => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m ()
- withMultiStates :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m (a, HList s1)
- withMultiStatesAS :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m (a, HList s1)
- withMultiStatesSA :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m (HList s1, a)
- withMultiStatesA :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m a
- withMultiStatesS :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m (HList s1)
- withMultiStates_ :: (Functor m, Monad m) => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m ()
- inflateState :: (Monad m, ContainsType s ss) => StateT s m a -> MultiStateT ss m a
- inflateReader :: (Monad m, ContainsType r ss) => ReaderT r m a -> MultiStateT ss m a
- inflateWriter :: (Monad m, ContainsType w ss, Monoid w) => WriterT w m a -> MultiStateT ss m a
- mapMultiStateT :: (m (a, HList w) -> m' (a', HList w)) -> MultiStateT w m a -> MultiStateT w m' a'
- mGetRaw :: Monad m => MultiStateT a m (HList a)
- mPutRaw :: Monad m => HList s -> MultiStateT s m ()
MultiStateT
newtype MultiStateT x m a Source #
A State transformer monad patameterized by:
- x - The list of types constituting the state,
- m - The inner monad.
MultiStateT
corresponds to mtl's StateT
, but can contain
a heterogenous list of types.
This heterogenous list is represented using Types.Data.List, i.e:
'[]
- The empty list,a ': b
- A list wherea
is an arbitrary type andb
is the rest list.
For example,
MultiStateT '[Int, Bool] :: (* -> *) -> (* -> *)
is a State wrapper containing the types [Int, Bool].
MultiStateT | |
|
MonadBase b m => MonadBase b (MultiStateT s m) Source # | |
MonadBaseControl b m => MonadBaseControl b (MultiStateT s m) Source # | |
MonadState s m => MonadState s (MultiStateT c m) Source # | |
MonadWriter w m => MonadWriter w (MultiStateT c m) Source # | |
(Monad m, ContainsType a c) => MonadMultiState a (MultiStateT c m) Source # | |
MonadTrans (MultiStateT x) Source # | |
MonadTransControl (MultiStateT s) Source # | |
Monad m => Monad (MultiStateT x m) Source # | |
Functor f => Functor (MultiStateT x f) Source # | |
MonadFix m => MonadFix (MultiStateT s m) Source # | |
(Applicative m, Monad m) => Applicative (MultiStateT x m) Source # | |
MonadIO m => MonadIO (MultiStateT c m) Source # | |
(Functor m, Applicative m, MonadPlus m) => Alternative (MultiStateT s m) Source # | |
MonadPlus m => MonadPlus (MultiStateT s m) Source # | |
type StT (MultiStateT s) a Source # | |
type StM (MultiStateT s m) a Source # | |
type MultiStateTNull = MultiStateT '[] Source #
A MultiState transformer carrying an empty state.
type MultiState x = MultiStateT x Identity Source #
A state monad parameterized by the list of types x of the state to carry.
Similar to State s = StateT s Identity
MonadMultiState class
class Monad m => MonadMultiState a m where Source #
All methods must be defined.
The idea is: Any monad stack is instance of MonadMultiState a
, iff
the stack contains a MultiStateT x
with a element of x.
state set function for values of type a
.
state get function for values of type a
.
(MonadTrans t, Monad (t m), MonadMultiState a m) => MonadMultiState a (t m) Source # | |
(Monad m, ContainsType a c) => MonadMultiState a (MultiStateT c m) Source # | |
(Monad m, ContainsType a c) => MonadMultiState a (MultiStateT c m) Source # | |
(Monad m, ContainsType a s) => MonadMultiState a (MultiRWST r w s m) Source # | |
(Monad m, ContainsType a s) => MonadMultiState a (MultiRWST r w s m) Source # | |
run-functions
runMultiStateT :: Functor m => HList s -> MultiStateT s m a -> m (a, HList s) Source #
runMultiStateTAS :: Functor m => HList s -> MultiStateT s m a -> m (a, HList s) Source #
runMultiStateTSA :: Monad m => HList s -> MultiStateT s m a -> m (HList s, a) Source #
runMultiStateTA :: Monad m => HList s -> MultiStateT s m a -> m a Source #
runMultiStateTS :: Monad m => HList s -> MultiStateT s m a -> m (HList s) Source #
runMultiStateT_ :: Functor m => HList s -> MultiStateT s m a -> m () Source #
runMultiStateTNil :: Monad m => MultiStateT '[] m a -> m a Source #
runMultiStateTNil_ :: Functor m => MultiStateT '[] m a -> m () Source #
with-functions (single state)
withMultiState :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m (a, s) Source #
withMultiStateAS :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m (a, s) Source #
withMultiStateSA :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m (s, a) Source #
withMultiStateA :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m a Source #
withMultiStateS :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m s Source #
withMultiState_ :: (Functor m, Monad m) => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m () Source #
with-functions (multiple states)
withMultiStates :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m (a, HList s1) Source #
withMultiStatesAS :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m (a, HList s1) Source #
withMultiStatesSA :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m (HList s1, a) Source #
withMultiStatesA :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m a Source #
withMultiStatesS :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m (HList s1) Source #
withMultiStates_ :: (Functor m, Monad m) => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m () Source #
inflate-functions (run single state in multiple states)
inflateState :: (Monad m, ContainsType s ss) => StateT s m a -> MultiStateT ss m a Source #
inflateReader :: (Monad m, ContainsType r ss) => ReaderT r m a -> MultiStateT ss m a Source #
inflateWriter :: (Monad m, ContainsType w ss, Monoid w) => WriterT w m a -> MultiStateT ss m a Source #
other functions
mapMultiStateT :: (m (a, HList w) -> m' (a', HList w)) -> MultiStateT w m a -> MultiStateT w m' a' Source #
Map both the return value and the state of a computation using the given function.