on master help sign in
Simplify runner functions
2248afaHarendra Kumar
src/Asyncly/RunAsync.hs+7−3
@@ -83,8 +83,11 @@ runAsynclyLogged lref m = run Nothing m
83 where
83 where
84
84
85 stop = return ()
85 stop = return ()
86+
86 {-# INLINE yield #-}
87 {-# INLINE yield #-}
87− yield _ c r = maybe stop (\x -> (run c x)) r
88+ yield _ _ Nothing = stop
89+ yield _ c (Just x) = run c x
90+
88 run ct mx = (runAsyncT mx) ct stop yield
91 run ct mx = (runAsyncT mx) ct stop yield
89
92
90runAsyncly :: MonadAsync m => AsynclyT m a -> m ()
93runAsyncly :: MonadAsync m => AsynclyT m a -> m ()
@@ -99,9 +102,10 @@ toList m = run Nothing m
99 where
102 where
100
103
101 stop = return []
104 stop = return []
102− done a = return [a]
105+
103 {-# INLINE yield #-}
106 {-# INLINE yield #-}
107+ yield a _ Nothing = return [a]
104− yield a c r = maybe (done a) (\x -> liftM (a :) (run c x)) r
108+ yield a c (Just x) = liftM (a :) (run c x)
105
109
106 {-# INLINE run #-}
110 {-# INLINE run #-}
107 run ctx mx = (runAsyncT mx) ctx stop yield
111 run ctx mx = (runAsyncT mx) ctx stop yield