-- 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.
@package mstate
@version 0.1.3
-- | MState: A consistent State monad for concurrent applications.
module Control.Concurrent.MState
-- | The MState is an abstract data definition for a State monad which can
-- be used in concurrent applications. It can be accessed with
-- evalMState and execMState. To start a new state
-- thread use forkM.
data MState t m a
-- | Run the MState and return both, the function value and the state value
runMState :: Forkable m => MState t m a -> t -> m (a, t)
-- | Evaluate the MState monad with the given initial state, throwing away
-- the final state stored in the MVar.
evalMState :: Forkable m => MState t m a -> t -> m a
-- | Execute the MState monad with a given initial state. Returns the value
-- of the final state.
execMState :: Forkable 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.mapState for
-- more information.
mapMState :: (MonadIO m, MonadIO n) => (m (a, t) -> n (b, t)) -> MState t m a -> MState t n b
-- | Apply this function to this state and return the resulting state.
withMState :: MonadIO m => (t -> t) -> MState t m a -> MState t m a
-- | Modify the MState. Block all other threads from accessing the state.
modifyM :: MonadIO m => (t -> t) -> MState t m ()
-- | The class which is needed to start new threads in the MState monad.
-- Don't confuse this with forkM which should be used to fork
-- new threads!
class MonadIO m => Forkable m
fork :: Forkable m => m () -> m ThreadId
-- | Start a new thread, using forkIO. The main process will wait
-- for all child processes to finish.
forkM :: Forkable m => MState t m () -> MState t m ThreadId
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)
instance Forkable (ReaderT s IO)
instance Forkable IO