on master help sign in
add noinline pragma for bind
commit9ec9c527e3114b9a690b7b93315952e347c42417 authorHarendra Kumar <harendra.kumar@gmail.com> dateWed 19 Jul 2017, 08:58 (9 years ago) parente1fc30a
1 file changed+14−9
src/Asyncly/AsyncT.hs+14−9
src/Asyncly/AsyncT.hs+14−9
@@ -202,15 +202,20 @@ type MonadAsync m = (MonadIO m, MonadBaseControl IO m, MonadThrow m)
202202
203203instance MonadAsync m => Monad (AsyncT m) where
204204 return a = AsyncT . return $ Just a
205− m >>= f = AsyncT $ do
206− modify $ \Context {continuations = fs, ..} ->
207− Context {continuations = (unsafeCoerce f) : fs, ..}
208− x <- runAsyncT m
209− modify $ \Context {continuations = (_ : fs), ..} ->
210− Context {continuations = fs, ..}
211− case x of
212− Just y -> runAsyncT $ f y
213− Nothing -> return Nothing
205+ m >>= f = bind
206+
207+ where
208+
209+ {-# NOINLINE[1] bind #-}
210+ bind = AsyncT $ do
211+ modify $ \Context {continuations = fs, ..} ->
212+ Context {continuations = (unsafeCoerce f) : fs, ..}
213+ x <- runAsyncT m
214+ modify $ \Context {continuations = (_ : fs), ..} ->
215+ Context {continuations = fs, ..}
216+ case x of
217+ Just y -> runAsyncT $ f y
218+ Nothing -> return Nothing
214219
215220------------------------------------------------------------------------------
216221-- Functor