monad-task-0.2.0: A monad transformer that turns event processing into co-routine programming.

Safe HaskellNone
LanguageHaskell98

Control.Monad.Trans.Task

Contents

Synopsis

Task monad transformer

newtype TaskT e m a Source #

Task monad transformer.

Constructors

TaskT 

Fields

Instances

MonadState s m => MonadState s (TaskT e m) Source # 

Methods

get :: TaskT e m s #

put :: s -> TaskT e m () #

state :: (s -> (a, s)) -> TaskT e m a #

MonadReader s m => MonadReader s (TaskT e m) Source # 

Methods

ask :: TaskT e m s #

local :: (s -> s) -> TaskT e m a -> TaskT e m a #

reader :: (s -> a) -> TaskT e m a #

Monad m => MonadTask e (TaskT e m) Source # 

Methods

yield :: TaskT e m () Source #

fork :: TaskT e m a -> TaskT e m () Source #

watch :: (e -> Maybe a) -> TaskT e m a Source #

signal :: e -> TaskT e m () Source #

exit :: TaskT e m () Source #

MonadTrans (TaskT e) Source # 

Methods

lift :: Monad m => m a -> TaskT e m a #

Monad m => Monad (TaskT e m) Source # 

Methods

(>>=) :: TaskT e m a -> (a -> TaskT e m b) -> TaskT e m b #

(>>) :: TaskT e m a -> TaskT e m b -> TaskT e m b #

return :: a -> TaskT e m a #

fail :: String -> TaskT e m a #

Functor (TaskT e m) Source # 

Methods

fmap :: (a -> b) -> TaskT e m a -> TaskT e m b #

(<$) :: a -> TaskT e m b -> TaskT e m a #

Applicative (TaskT e m) Source # 

Methods

pure :: a -> TaskT e m a #

(<*>) :: TaskT e m (a -> b) -> TaskT e m a -> TaskT e m b #

liftA2 :: (a -> b -> c) -> TaskT e m a -> TaskT e m b -> TaskT e m c #

(*>) :: TaskT e m a -> TaskT e m b -> TaskT e m b #

(<*) :: TaskT e m a -> TaskT e m b -> TaskT e m a #

MonadIO m => MonadIO (TaskT e m) Source # 

Methods

liftIO :: IO a -> TaskT e m a #

Trace of a base monad

data Trace m e where Source #

A Trace m e represents the control flow of a mult-threaded task monad defined over a base monad m and event type e.

Constructors

EXIT :: Trace m e 
RET :: Trace m e 
YIELD :: m (Trace m e) -> Trace m e 
FORK :: m (Trace m e) -> m (Trace m e) -> Trace m e 
WATCH :: (e -> Maybe v) -> (v -> m (Trace m e)) -> Trace m e 
SIGNAL :: e -> m (Trace m e) -> Trace m e 

runTrace :: Monad m => m (Trace m e) -> m () Source #

runTrace runs a trace to its completion in the base monad with a simple round-robin scheduler.

Task functions

taskToTrace :: Monad m => TaskT e m a -> m (Trace m e) Source #

tasktoTrace CPS-converts a task monad into a trace in its base monad.

runTask :: Monad m => TaskT e m a -> m () Source #

runTask runs a task monad until to its completion, i.e., no more active tasks to run, or until it exits.