on master help sign in
Short circuit Skip case in toStreamK
35ba2c3Harendra Kumar
src/Streamly/Internal/Data/Stream/StreamD/Type.hs+8−6
@@ -131,12 +131,14 @@ fromStreamK = Stream step
131toStreamK :: Monad m => Stream m a -> K.Stream m a
131toStreamK :: Monad m => Stream m a -> K.Stream m a
132toStreamK (Stream step state) = go state
132toStreamK (Stream step state) = go state
133 where
133 where
134− go st = K.mkStream $ \gst yld sng stp -> do
134+ go st = K.mkStream $ \gst yld _ stp ->
135+ let go' ss = do
135− r <- step gst st
136+ r <- step gst ss
136− case r of
137+ case r of
137− Yield x s -> yld x (go s)
138+ Yield x s -> yld x (go s)
138− Skip s -> K.foldStreamShared gst yld sng stp $ go s
139+ Skip s -> go' s
139− Stop -> stp
140+ Stop -> stp
141+ in go' st
140
142
141#ifndef DISABLE_FUSION
143#ifndef DISABLE_FUSION
142{-# RULES "fromStreamK/toStreamK fusion"
144{-# RULES "fromStreamK/toStreamK fusion"