@@ -45,7 +45,7 @@ import Duct.Event
46-- import Debug.Trace
46-- import Debug.Trace
48−newtype AsyncT m a = AsyncT { runAsyncT :: StateT EventF m (Maybe a) }
48+newtype AsyncT m a = AsyncT { runAsyncT :: StateT Context m (Maybe a) }
50------------------------------------------------------------------------------
50------------------------------------------------------------------------------
51-- Remote data types
51-- Remote data types
@@ -148,10 +148,10 @@ instance Monad m => Monad (AsyncT m) where
148 -- Save the 'm' and 'f', in case we migrate to a new thread before this
148 -- Save the 'm' and 'f', in case we migrate to a new thread before this
149 -- bind operation completes, we run the operation manually in the new
149 -- bind operation completes, we run the operation manually in the new
150 -- thread.
150 -- thread.
151− modify $ \EventF { fstack = fs, .. } ->
151+ modify $ \Context { fstack = fs, .. } ->
152− EventF { currentm = unsafeCoerce m
152+ Context { currentm = unsafeCoerce m
153− , fstack = unsafeCoerce f : fs
153+ , fstack = unsafeCoerce f : fs
156 -- Inner bind operations in 'm' add their 'f' to fstack. If we migrate to
156 -- Inner bind operations in 'm' add their 'f' to fstack. If we migrate to
157 -- a new thread somewhere in the middle we unwind the fstack and run these
157 -- a new thread somewhere in the middle we unwind the fstack and run these
@@ -162,10 +162,10 @@ instance Monad m => Monad (AsyncT m) where
162 Nothing -> empty
162 Nothing -> empty
163 Just x -> f x
163 Just x -> f x
165− modify $ \EventF { fstack = fs, .. } ->
165+ modify $ \Context { fstack = fs, .. } ->
166− EventF { currentm = unsafeCoerce res
166+ Context { currentm = unsafeCoerce res
167− , fstack = tailsafe fs
167+ , fstack = tailsafe fs
170 runAsyncT res
170 runAsyncT res
@@ -242,7 +242,7 @@ instance MonadTrans AsyncT where
242 lift mx = AsyncT $ lift mx >>= return . Just
242 lift mx = AsyncT $ lift mx >>= return . Just
244instance MonadTransControl AsyncT where
244instance MonadTransControl AsyncT where
245− type StT AsyncT a = (Maybe a, EventF)
245+ type StT AsyncT a = (Maybe a, Context)
246 liftWith f = AsyncT $ StateT $ \s ->
246 liftWith f = AsyncT $ StateT $ \s ->
247 liftM (\x -> (Just x, s))
247 liftM (\x -> (Just x, s))
248 (f $ \t -> runStateT (runAsyncT t) s)
248 (f $ \t -> runStateT (runAsyncT t) s)
@@ -284,13 +284,13 @@ waitForChildren chan pendingRef = do
284------------------------------------------------------------------------------
284------------------------------------------------------------------------------
286-- | Run a transient computation with a default initial state
286-- | Run a transient computation with a default initial state
287−runTransient :: forall m a. MonadIO m => AsyncT m a -> m (Maybe a, EventF)
287+runTransient :: forall m a. MonadIO m => AsyncT m a -> m (Maybe a, Context)
288runTransient t = do
288runTransient t = do
289 childChan <- liftIO $ atomically newTChan
289 childChan <- liftIO $ atomically newTChan
290 pendingRef <- liftIO $ newIORef []
290 pendingRef <- liftIO $ newIORef []
291 credit <- liftIO $ newIORef maxBound
291 credit <- liftIO $ newIORef maxBound
293− r <- runStateT (runAsyncT t) $ initEventF
293+ r <- runStateT (runAsyncT t) $ initContext
294 (empty :: AsyncT m a) childChan pendingRef credit
294 (empty :: AsyncT m a) childChan pendingRef credit
296 waitForChildren childChan pendingRef
296 waitForChildren childChan pendingRef
@@ -362,7 +362,7 @@ delSData x = AsyncT $ delData x >> return (Just ())
362-- MonadState for AsyncT m
362-- MonadState for AsyncT m
363------------------------------------------------------------------------------
363------------------------------------------------------------------------------
365−instance (Monad m, Monad (AsyncT m)) => MonadState EventF (AsyncT m) where
365+instance (Monad m, Monad (AsyncT m)) => MonadState Context (AsyncT m) where
366 get = AsyncT $ get >>= return . Just
366 get = AsyncT $ get >>= return . Just
367 put x = AsyncT $ put x >> return (Just ())
367 put x = AsyncT $ put x >> return (Just ())
368 state f = AsyncT $ do
368 state f = AsyncT $ do