Safe Haskell | None |
---|---|
Language | Haskell2010 |
State monad with multiple states (extensible)
Similar to the multistate package, with the following differences (as of 0.7.0.0): * don't pollute Data.HList.HList * use HArray instead of a HList, for fast indexing
- type MStateT (s :: [*]) m a = StateT (HArray s) m a
- type MState (s :: [*]) a = MStateT s Identity a
- mSet :: (Monad m, HArrayIndexT a s) => a -> MStateT s m ()
- mGet :: (Monad m, HArrayIndexT a s) => MStateT s m a
- mTryGet :: (Monad m, HArrayTryIndexT a s) => MStateT s m (Maybe a)
- mModify :: (Monad m, HArrayIndexT a s) => (a -> a) -> MStateT s m ()
- mModify' :: (Monad m, HArrayIndexT a s) => (a -> a) -> MStateT s m ()
- mWith :: forall s a m b. Monad m => a -> MStateT (a ': s) m b -> MStateT s m b
- runMState :: MState s a -> HArray s -> (a, HArray s)
- evalMState :: MState s a -> HArray s -> a
- execMState :: MState s a -> HArray s -> HArray s
- liftMStateT :: Monad m => MStateT xs m x -> HArrayT m xs (x ': xs)
- (>~:>) :: Monad m => HArrayT m xs ys -> MStateT ys m y -> HArrayT m xs (y ': ys)
- (>:>) :: Monad m => MStateT xs m x -> MStateT (x ': xs) m y -> HArrayT m xs (y ': (x ': xs))
Documentation
type MStateT (s :: [*]) m a = StateT (HArray s) m a Source #
Multi-state monad transformer
States are stacked in a heterogeneous array.
mTryGet :: (Monad m, HArrayTryIndexT a s) => MStateT s m (Maybe a) Source #
Try to get a value in the state
mModify :: (Monad m, HArrayIndexT a s) => (a -> a) -> MStateT s m () Source #
Modify a value in the state
mModify' :: (Monad m, HArrayIndexT a s) => (a -> a) -> MStateT s m () Source #
Modify a value in the state (strict version)
mWith :: forall s a m b. Monad m => a -> MStateT (a ': s) m b -> MStateT s m b Source #
Execute an action with an extended state
evalMState :: MState s a -> HArray s -> a Source #
Evaluate MState
liftMStateT :: Monad m => MStateT xs m x -> HArrayT m xs (x ': xs) Source #
Lift a multi-state into an HArray transformer