@@ -34,41 +34,6 @@ import Unsafe.Coerce (unsafeCoerce)
34import Duct.AsyncT
34import Duct.AsyncT
35import Duct.Event
35import Duct.Event
38−-- | Run a transient computation with a given initial state
39−runTransState :: EventF -> AsyncT m x -> m (Maybe x, EventF)
40−runTransState st x = runStateT (runAsyncT x) st
42−-- | Get the continuation context: closure, continuation, state, child threads etc
43−getCont :: Monad m => AsyncT m EventF
44−getCont = AsyncT $ Just <$> get
46−-- | Run the closure and the continuation using its own state data.
47−runCont' :: (MonadIO m, Monad (AsyncT m)) => EventF -> m (Maybe a, EventF)
48−runCont' cont = runStateT (runCont cont) cont
50−-- | Save a closure and continuation, run the closure, restore the old continuation.
51−-- | NOTE: The old closure is discarded.
52−withContinuation :: MonadIO m => b -> AsyncT m a -> AsyncT m a
53−withContinuation c mx = do
54− EventF { fcomp = fs, .. } <- get
55− put $ EventF { xcomp = unsafeCoerce mx
56− , fcomp = unsafeCoerce c : fs
62−-- | Run a chain of continuations.
63−-- WARNING: It is up to the programmer to assure that each continuation typechecks
64−-- with the next, and that the parameter type match the input of the first
66−-- NOTE: Normally this makes sense to stop the current flow with `stop` after the
68−runContinuations :: MonadIO m => [a -> AsyncT m b] -> c -> AsyncT m d
69−runContinuations fs x = compose (unsafeCoerce fs) x
72------------------------------------------------------------------------------
37------------------------------------------------------------------------------
73-- Utilities
38-- Utilities
74------------------------------------------------------------------------------
39------------------------------------------------------------------------------