on master help sign in
add noinline pragma for bind
9ec9c52Harendra Kumar
src/Asyncly/AsyncT.hs+14−9
@@ -202,15 +202,20 @@ type MonadAsync m = (MonadIO m, MonadBaseControl IO m, MonadThrow m)
202
202
203instance MonadAsync m => Monad (AsyncT m) where
203instance MonadAsync m => Monad (AsyncT m) where
204 return a = AsyncT . return $ Just a
204 return a = AsyncT . return $ Just a
205+ m >>= f = bind
206+
207+ where
208+
209+ {-# NOINLINE[1] bind #-}
205− m >>= f = AsyncT $ do
210+ bind = AsyncT $ do
206− modify $ \Context {continuations = fs, ..} ->
211+ modify $ \Context {continuations = fs, ..} ->
207− Context {continuations = (unsafeCoerce f) : fs, ..}
212+ Context {continuations = (unsafeCoerce f) : fs, ..}
208− x <- runAsyncT m
213+ x <- runAsyncT m
209− modify $ \Context {continuations = (_ : fs), ..} ->
214+ modify $ \Context {continuations = (_ : fs), ..} ->
210− Context {continuations = fs, ..}
215+ Context {continuations = fs, ..}
211− case x of
216+ case x of
212− Just y -> runAsyncT $ f y
217+ Just y -> runAsyncT $ f y
213− Nothing -> return Nothing
218+ Nothing -> return Nothing
214
219
215------------------------------------------------------------------------------
220------------------------------------------------------------------------------
216-- Functor
221-- Functor