-- 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.8
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 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 Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Control.Concurrent.MState.MState t m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Concurrent.MState.MState t m)
instance GHC.Base.Functor f => GHC.Base.Functor (Control.Concurrent.MState.MState t f)
instance (GHC.Base.Applicative m, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Concurrent.MState.MState t m)
instance (GHC.Base.Alternative m, GHC.Base.Monad m) => GHC.Base.Alternative (Control.Concurrent.MState.MState t m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Control.Concurrent.MState.MState t m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.State.Class.MonadState t (Control.Concurrent.MState.MState t m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Concurrent.MState.MState t m)
instance Control.Monad.Trans.Class.MonadTrans (Control.Concurrent.MState.MState t)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Concurrent.MState.MState t m)
instance Control.Monad.Cont.Class.MonadCont m => Control.Monad.Cont.Class.MonadCont (Control.Concurrent.MState.MState t m)
instance Control.Monad.Error.Class.MonadError e m => Control.Monad.Error.Class.MonadError e (Control.Concurrent.MState.MState t m)
instance Control.Monad.Reader.Class.MonadReader r m => Control.Monad.Reader.Class.MonadReader r (Control.Concurrent.MState.MState t m)
instance Control.Monad.Writer.Class.MonadWriter w m => Control.Monad.Writer.Class.MonadWriter w (Control.Concurrent.MState.MState t m)
instance Control.Monad.Trans.Peel.MonadTransPeel (Control.Concurrent.MState.MState t)
instance Control.Monad.IO.Peel.MonadPeelIO m => Control.Monad.IO.Peel.MonadPeelIO (Control.Concurrent.MState.MState t m)