Manatee.Toolkit.General.State
- modifyM :: (Monad m, MonadTrans t, MonadState a (t m)) => (a -> m a) -> t m ()
- modifyM_ :: (Monad m, MonadTrans t, MonadState a1 (t m)) => (a1 -> m a) -> (a -> a1) -> (a -> a2) -> t m a2
- modifyM' :: (Monad m, MonadTrans t, MonadState a1 (t m)) => (a1 -> m a) -> (a -> a1) -> t m ()
- modifyFst :: MonadState (t, t1) m => ((t, t1) -> t) -> m ()
- modifySnd :: MonadState (t, t1) m => ((t, t1) -> t1) -> m ()
- modifyFstM :: (Monad m, MonadTrans t1, MonadState (a, t) (t1 m)) => ((a, t) -> m a) -> t1 m ()
- modifySndM :: (Monad m, MonadTrans t1, MonadState (t, a) (t1 m)) => ((t, a) -> m a) -> t1 m ()
- getM :: (MonadState a (t m), MonadTrans t, Monad m) => (a -> m a1) -> t m a1
- runStateT_ :: b -> StateT b m a -> m (a, b)
- runStateT' :: Functor f => b -> StateT b f a -> f b
- runTVarStateT :: TVar a -> (a -> StateT a IO b) -> IO ()
- runTVarTupeStateT :: (TVar a, TVar b) -> (a -> b -> StateT (a, b) IO c) -> IO ()
Documentation
modifyM :: (Monad m, MonadTrans t, MonadState a (t m)) => (a -> m a) -> t m ()Source
Like modify
, except use Monad wrap update function.
modifyM_ :: (Monad m, MonadTrans t, MonadState a1 (t m)) => (a1 -> m a) -> (a -> a1) -> (a -> a2) -> t m a2Source
Like modifyM
,
but add two functions filter new state and return value.
This is handy when function return result including state.
Example, state is (a,b), and function return (a,b,c),
then you can write: result <- modifyM_ f fst snd.
modifyM' :: (Monad m, MonadTrans t, MonadState a1 (t m)) => (a1 -> m a) -> (a -> a1) -> t m ()Source
Like modifyM_
, except don't return value.
modifyFst :: MonadState (t, t1) m => ((t, t1) -> t) -> m ()Source
Modify fst state of tuple.
modifySnd :: MonadState (t, t1) m => ((t, t1) -> t1) -> m ()Source
Modify snd state of tuple.
modifyFstM :: (Monad m, MonadTrans t1, MonadState (a, t) (t1 m)) => ((a, t) -> m a) -> t1 m ()Source
Like modifyFst
, except use moand wrap function.
modifySndM :: (Monad m, MonadTrans t1, MonadState (t, a) (t1 m)) => ((t, a) -> m a) -> t1 m ()Source
Like modifySnd
, except use moand wrap function.
getM :: (MonadState a (t m), MonadTrans t, Monad m) => (a -> m a1) -> t m a1Source
Like get
, except use Monad wrap function.
runStateT_ :: b -> StateT b m a -> m (a, b)Source
Like runStateT
, just reverse arguments order.
runStateT' :: Functor f => b -> StateT b f a -> f bSource
Like runStateT_
, but just return last argument.
It's useful that you just want use runStateT wrap *one* state.
runTVarTupeStateT :: (TVar a, TVar b) -> (a -> b -> StateT (a, b) IO c) -> IO ()Source
Like runTVarStateT
, but handle tuple TVar.