-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | MState: A consistent State monad for concurrent applications.
--
-- MState offers a State monad which can be used in concurrent
-- applications. It also manages new threads and waits until the whole
-- state monad has been evaluated/executed before it returns the state
-- values (if desired).
@package mstate
@version 0.2.7
-- | MState: A consistent state monad for concurrent applications.
module Control.Concurrent.MState
-- | The MState monad is a state monad for concurrent applications. To
-- create a new thread sharing the same (modifiable) state use the
-- forkM function.
data MState t m a
-- | Run a MState application, returning both, the function value
-- and the final state. Note that this function has to wait for all
-- threads to finish before it can return the final state.
runMState :: MonadPeelIO m => MState t m a -> t -> m (a, t)
-- | Run a MState application, ignoring the final state. If the
-- first argument is True this function will wait for all threads
-- to finish before returning the final result, otherwise it will return
-- the function value as soon as its acquired.
evalMState :: MonadPeelIO m => Bool -> MState t m a -> t -> m a
-- | Run a MState application, ignoring the function value. This
-- function will wait for all threads to finish before returning the
-- final state.
execMState :: MonadPeelIO m => MState t m a -> t -> m t
-- | Map a stateful computation from one (return value, state)
-- pair to another. See Control.Monad.State.Lazy for more
-- information. Be aware that both MStates still share the same state.
mapMState :: (MonadIO m, MonadIO n) => (m (a, t) -> n (b, t)) -> MState t m a -> MState t n b
mapMState_ :: (MonadIO m, MonadIO n) => (m a -> n b) -> MState t m a -> MState t n b
-- | Modify the MState, block all other threads from accessing the
-- state in the meantime (using atomically from the
-- Control.Concurrent.STM library).
modifyM :: MonadIO m => (t -> (a, t)) -> MState t m a
modifyM_ :: MonadIO m => (t -> t) -> MState t m ()
-- | Start a new stateful thread.
forkM :: MonadPeelIO m => MState t m () -> MState t m ThreadId
forkM_ :: MonadPeelIO m => MState t m () -> MState t m ()
-- | Kill all threads in the current MState application.
killMState :: MonadPeelIO m => MState t m ()
-- | Wait for a thread to finish
waitM :: MonadPeelIO m => ThreadId -> MState t m ()
instance MonadPeelIO m => MonadPeelIO (MState t m)
instance MonadTransPeel (MState t)
instance MonadWriter w m => MonadWriter w (MState t m)
instance MonadReader r m => MonadReader r (MState t m)
instance MonadError e m => MonadError e (MState t m)
instance MonadCont m => MonadCont (MState t m)
instance MonadIO m => MonadIO (MState t m)
instance MonadTrans (MState t)
instance MonadFix m => MonadFix (MState t m)
instance MonadIO m => MonadState t (MState t m)
instance MonadPlus m => MonadPlus (MState t m)
instance (Alternative m, Monad m) => Alternative (MState t m)
instance (Applicative m, Monad m) => Applicative (MState t m)
instance Functor f => Functor (MState t f)
instance Monad m => Monad (MState t m)