-- 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.2
-- | 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 :: (Forkable m, 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 :: (Forkable m, 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 :: (Forkable m, 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
-- | 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 ()
-- | Typeclass for forkable monads. This is the basic information about how
-- to fork a new thread in the current monad. To start a new thread in a
-- MState application you should always use forkM.
class MonadIO m => Forkable m
fork :: Forkable m => m () -> m ThreadId
-- | Start a new thread, using the fork function from the
-- Forkable type class. When using this function, the main process
-- will wait for all child processes to finish (if desired).
forkM :: (MonadPeelIO m, Forkable m) => MState t m () -> MState t m ThreadId
-- | Kill all threads in the current MState application.
killMState :: Forkable m => MState t m ()
instance (Error e, Forkable m) => Forkable (ErrorT e m)
instance Forkable m => Forkable (ReaderT s m)
instance Forkable IO
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 Monad m => Functor (MState t m)
instance Monad m => Monad (MState t m)