on master help sign in
Change pollCount signature
cdfda9bRanjeet Kumar Ranjan
benchmark/Streamly/Benchmark/Prelude/Serial/Transformation.hs+2−2
@@ -141,11 +141,11 @@ tap n = composeN n $ S.tap FL.sum
141{-# INLINE pollCounts #-}
141{-# INLINE pollCounts #-}
142pollCounts :: Int -> SerialT IO Int -> IO ()
142pollCounts :: Int -> SerialT IO Int -> IO ()
143pollCounts n =
143pollCounts n =
144− composeN n (Internal.pollCounts (const True) f FL.drain)
144+ composeN n (Internal.pollCounts (const True) f)
145
145
146 where
146 where
147
147
148− f = Internal.rollingMap2 (-) . Internal.delayPost 1
148+ f = S.drain . Internal.rollingMap2 (-) . Internal.delayPost 1
149
149
150{-# INLINE timestamped #-}
150{-# INLINE timestamped #-}
151timestamped :: (S.MonadAsync m) => SerialT m Int -> m ()
151timestamped :: (S.MonadAsync m) => SerialT m Int -> m ()
core/src/Streamly/Internal/Data/Stream/StreamD/Transform.hs+4−5
@@ -333,11 +333,10 @@ tapOffsetEvery offset n (Fold fstep initial extract) (Stream step state) =
333pollCounts
333pollCounts
334 :: MonadAsync m
334 :: MonadAsync m
335 => (a -> Bool)
335 => (a -> Bool)
336− -> (Stream m Int -> Stream m Int)
336+ -> (Stream m Int -> m b)
337− -> Fold m Int b
338 -> Stream m a
337 -> Stream m a
339 -> Stream m a
338 -> Stream m a
340−pollCounts predicate transf fld (Stream step state) = Stream step' Nothing
339+pollCounts predicate fld (Stream step state) = Stream step' Nothing
341 where
340 where
342
341
343 {-# INLINE_LATE step' #-}
342 {-# INLINE_LATE step' #-}
@@ -347,8 +346,8 @@ pollCounts predicate transf fld (Stream step state) = Stream step' Nothing
347 -- However, an Int on a 32-bit machine may overflow quickly.
346 -- However, an Int on a 32-bit machine may overflow quickly.
348 countVar <- liftIO $ Prim.newIORef (0 :: Int)
347 countVar <- liftIO $ Prim.newIORef (0 :: Int)
349 tid <- forkManaged
348 tid <- forkManaged
350− $ void $ fold fld
349+ $ void $ fld
351− $ transf $ Prim.toStreamD countVar
350+ $ Prim.toStreamD countVar
352 return $ Skip (Just (countVar, tid, state))
351 return $ Skip (Just (countVar, tid, state))
353
352
354 step' gst (Just (countVar, tid, st)) = do
353 step' gst (Just (countVar, tid, st)) = do
src/Streamly/Internal/Data/Stream/IsStream/Transform.hs+3−4
@@ -574,13 +574,12 @@ distributeAsync_ = flip (Prelude.foldr tapAsyncK)
574pollCounts ::
574pollCounts ::
575 (IsStream t, MonadAsync m)
575 (IsStream t, MonadAsync m)
576 => (a -> Bool)
576 => (a -> Bool)
577− -> (t m Int -> t m Int)
577+ -> (t m Int -> m b)
578− -> Fold m Int b
579 -> t m a
578 -> t m a
580 -> t m a
579 -> t m a
581−pollCounts predicate transf f xs =
580+pollCounts predicate f xs =
582 fromStreamD
581 fromStreamD
583− $ D.pollCounts predicate (toStreamD . transf . fromStreamD) f
582+ $ D.pollCounts predicate (f . fromStreamD)
584 $ toStreamD xs
583 $ toStreamD xs
585
584
586-- | Apply a monadic function to each element flowing through the stream and
585-- | Apply a monadic function to each element flowing through the stream and