@@ -34,41 +34,6 @@ import Unsafe.Coerce (unsafeCoerce)
3434import Duct.AsyncT
3535import Duct.Event
3636
37−{-
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
41−
42−-- | Get the continuation context: closure, continuation, state, child threads etc
43−getCont :: Monad m => AsyncT m EventF
44−getCont = AsyncT $ Just <$> get
45−
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
49−
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
57− , .. }
58− r <- mx
59− restoreStack fs
60− return r
61−
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
65−-- continuation.
66−-- NOTE: Normally this makes sense to stop the current flow with `stop` after the
67−-- invocation.
68−runContinuations :: MonadIO m => [a -> AsyncT m b] -> c -> AsyncT m d
69−runContinuations fs x = compose (unsafeCoerce fs) x
70−-}
71−
7237------------------------------------------------------------------------------
7338-- Utilities
7439------------------------------------------------------------------------------