Copyright | Copyright (c) 2009-2017 David Sorokin <david.sorokin@gmail.com> |
---|---|
License | BSD3 |
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
- data ContParams m a
- data ContCancellation
- newtype Cont m a = Cont (ContParams m a -> Event m ())
- data ContId m
- data ContEvent
- data FrozenCont m a
- newContId :: MonadDES m => Simulation m (ContId m)
- contSignal :: ContId m -> Signal m ContEvent
- contCancellationInitiated :: MonadDES m => ContId m -> Event m Bool
- contCancellationInitiate :: MonadDES m => ContId m -> Event m ()
- contCancellationInitiating :: MonadDES m => ContId m -> Signal m ()
- contCancellationActivated :: MonadDES m => ContId m -> Event m Bool
- contCancellationBind :: MonadDES m => ContId m -> [ContId m] -> Event m (DisposableEvent m)
- contCancellationConnect :: MonadDES m => ContId m -> ContCancellation -> ContId m -> Event m (DisposableEvent m)
- contPreemptionBegun :: MonadDES m => ContId m -> Event m Bool
- contPreemptionBegin :: MonadDES m => ContId m -> Event m ()
- contPreemptionBeginning :: MonadDES m => ContId m -> Signal m ()
- contPreemptionEnd :: MonadDES m => ContId m -> Event m ()
- contPreemptionEnding :: MonadDES m => ContId m -> Signal m ()
- invokeCont :: ContParams m a -> Cont m a -> Event m ()
- runCont :: MonadDES m => Cont m a -> (a -> Event m ()) -> (SomeException -> Event m ()) -> (() -> Event m ()) -> ContId m -> Bool -> Event m ()
- rerunCont :: MonadDES m => Cont m a -> ContId m -> Cont m a
- spawnCont :: MonadDES m => ContCancellation -> Cont m () -> ContId m -> Cont m ()
- contParallel :: MonadDES m => [(Cont m a, ContId m)] -> Cont m [a]
- contParallel_ :: MonadDES m => [(Cont m a, ContId m)] -> Cont m ()
- catchCont :: (MonadDES m, Exception e) => Cont m a -> (e -> Cont m a) -> Cont m a
- finallyCont :: MonadDES m => Cont m a -> Cont m b -> Cont m a
- throwCont :: (MonadDES m, Exception e) => e -> Cont m a
- resumeCont :: MonadDES m => ContParams m a -> a -> Event m ()
- resumeECont :: MonadDES m => ContParams m a -> SomeException -> Event m ()
- reenterCont :: MonadDES m => ContParams m a -> a -> Event m ()
- freezeCont :: MonadDES m => ContParams m a -> Event m (FrozenCont m a)
- freezeContReentering :: MonadDES m => ContParams m a -> a -> Event m () -> Event m (FrozenCont m a)
- unfreezeCont :: FrozenCont m a -> Event m (Maybe (ContParams m a))
- substituteCont :: MonadDES m => ContParams m a -> (a -> Event m ()) -> ContParams m a
- contCanceled :: MonadDES m => ContParams m a -> Event m Bool
- contAwait :: MonadDES m => Signal m a -> Cont m a
- transferCont :: MonadDES m => Cont m () -> Cont m a
- traceCont :: MonadDES m => String -> Cont m a -> Cont m a
Documentation
data ContParams m a Source #
The continuation parameters.
data ContCancellation Source #
It defines how the parent and child computations should be cancelled.
CancelTogether | Cancel the both computations together. |
CancelChildAfterParent | Cancel the child if its parent is cancelled. |
CancelParentAfterChild | Cancel the parent if its child is cancelled. |
CancelInIsolation | Cancel the computations in isolation. |
The Cont
type is similar to the standard Cont monad
and F# async workflow but only the result of applying
the continuations return the Event
computation.
Cont (ContParams m a -> Event m ()) |
MonadDES m => MonadCompTrans Cont m Source # | |
MonadDES m => ParameterLift Cont m Source # | |
MonadDES m => SimulationLift Cont m Source # | |
MonadDES m => DynamicsLift Cont m Source # | |
MonadDES m => EventLift Cont m Source # | |
MonadDES m => Monad (Cont m) Source # | |
MonadDES m => Functor (Cont m) Source # | |
MonadDES m => Applicative (Cont m) Source # | |
(MonadDES m, MonadIO m) => MonadIO (Cont m) Source # | |
MonadDES m => MonadThrow (Cont m) Source # | |
MonadDES m => MonadCatch (Cont m) Source # | |
The event that occurs within the Cont
computation.
ContCancellationInitiating | Cancel the computation. |
ContPreemptionBeginning | Preempt the computation. |
ContPreemptionEnding | Proceed with the computation after if was preempted. |
data FrozenCont m a Source #
Represents a temporarily frozen computation.
contCancellationInitiated :: MonadDES m => ContId m -> Event m Bool Source #
Whether the cancellation was initiated.
contCancellationInitiating :: MonadDES m => ContId m -> Signal m () Source #
Signal when the cancellation is intiating.
contCancellationActivated :: MonadDES m => ContId m -> Event m Bool Source #
Whether the cancellation was activated.
contCancellationBind :: MonadDES m => ContId m -> [ContId m] -> Event m (DisposableEvent m) Source #
If the main computation is cancelled then all the nested ones will be cancelled too.
contCancellationConnect Source #
:: MonadDES m | |
=> ContId m | the parent |
-> ContCancellation | how to connect |
-> ContId m | the child |
-> Event m (DisposableEvent m) | computation of the disposable handler |
Connect the parent computation to the child one.
contPreemptionBegun :: MonadDES m => ContId m -> Event m Bool Source #
Whether the computation was preemtped.
contPreemptionBeginning :: MonadDES m => ContId m -> Signal m () Source #
Signal when the computation is preempted.
contPreemptionEnd :: MonadDES m => ContId m -> Event m () Source #
Proceed with the computation after it was preempted earlier.
contPreemptionEnding :: MonadDES m => ContId m -> Signal m () Source #
Signal when the computation is proceeded after it was preempted before.
invokeCont :: ContParams m a -> Cont m a -> Event m () Source #
Invoke the computation.
:: MonadDES m | |
=> Cont m a | the computation to run |
-> (a -> Event m ()) | the main branch |
-> (SomeException -> Event m ()) | the branch for handing exceptions |
-> (() -> Event m ()) | the branch for cancellation |
-> ContId m | the computation identifier |
-> Bool | whether to support the exception handling from the beginning |
-> Event m () |
Run the Cont
computation with the specified cancelation source
and flag indicating whether to catch exceptions from the beginning.
rerunCont :: MonadDES m => Cont m a -> ContId m -> Cont m a Source #
Rerun the Cont
computation with the specified identifier.
spawnCont :: MonadDES m => ContCancellation -> Cont m () -> ContId m -> Cont m () Source #
Run the Cont
computation in parallel but connect the computations.
:: MonadDES m | |
=> [(Cont m a, ContId m)] | the list of pairs: the nested computation, the computation identifier |
-> Cont m [a] |
Execute the specified computations in parallel within the current computation and return their results. The cancellation of any of the nested computations affects the current computation. The exception raised in any of the nested computations is propogated to the current computation as well (if the exception handling is supported).
Here word parallel
literally means that the computations are
actually executed on a single operating system thread but
they are processed simultaneously by the event queue.
:: MonadDES m | |
=> [(Cont m a, ContId m)] | the list of pairs: the nested computation, the computation identifier |
-> Cont m () |
A partial case of contParallel
when we are not interested in
the results but we are interested in the actions to be peformed by
the nested computations.
catchCont :: (MonadDES m, Exception e) => Cont m a -> (e -> Cont m a) -> Cont m a Source #
Exception handling within Cont
computations.
finallyCont :: MonadDES m => Cont m a -> Cont m b -> Cont m a Source #
A computation with finalization part.
throwCont :: (MonadDES m, Exception e) => e -> Cont m a Source #
Throw the exception with the further exception handling.
By some reason, an exception raised with help of the standard throw
function
is not handled properly within Cont
computation, altough it will be still handled
if it will be wrapped in the IO
monad. Therefore, you should use specialised
functions like the stated one that use the throw
function but within the IO
computation,
which allows already handling the exception.
resumeCont :: MonadDES m => ContParams m a -> a -> Event m () Source #
Resume the computation by the specified parameters.
resumeECont :: MonadDES m => ContParams m a -> SomeException -> Event m () Source #
Resume the exception handling by the specified parameters.
reenterCont :: MonadDES m => ContParams m a -> a -> Event m () Source #
Reenter the computation parameters when needed.
freezeCont :: MonadDES m => ContParams m a -> Event m (FrozenCont m a) Source #
Freeze the computation parameters temporarily.
freezeContReentering :: MonadDES m => ContParams m a -> a -> Event m () -> Event m (FrozenCont m a) Source #
Freeze the computation parameters specifying what should be done when reentering the computation.
unfreezeCont :: FrozenCont m a -> Event m (Maybe (ContParams m a)) Source #
Unfreeze the computation.
substituteCont :: MonadDES m => ContParams m a -> (a -> Event m ()) -> ContParams m a Source #
Substitute the continuation.
contCanceled :: MonadDES m => ContParams m a -> Event m Bool Source #
Test whether the computation is canceled.
transferCont :: MonadDES m => Cont m () -> Cont m a Source #
Like the GoTo statement it transfers the direction of computation,
but raises an exception when used within catchCont
or finallyCont
.