@@ -3778,15 +3778,16 @@ tapOffsetEvery offset n f xs =
37783778tapAsync :: (IsStream t, MonadAsync m) => FL.Fold m a b -> t m a -> t m a
37793779tapAsync f xs = D.fromStreamD $ D.tapAsync f (D.toStreamD xs)
37803780
3781−-- | Maintain the count of elements flowing in the stream and poll the count
3782−-- asynchronously from another thread. The count stream is transformed using
3783−-- the supplied transform and then folded using the supplied fold. The thread
3784−-- is automatically cleaned up if the stream stops or aborts due to exception.
3781+-- | @pollCounts predicate transform fold stream@ counts those elements in the
3782+-- stream that pass the @predicate@. The resulting count stream is sent to
3783+-- another thread which transforms it using @transform@ and then folds it using
3784+-- @fold@. The thread is automatically cleaned up if the stream stops or
3785+-- aborts due to exception.
37853786--
37863787-- For example, to print the count of elements processed every second:
37873788--
37883789-- @
3789−-- > S.drain $ S.pollCounts (rollingMap (-) . delayPost 1) (FL.drainBy print)
3790+-- > S.drain $ S.pollCounts (const True) (S.rollingMap (-) . S.delayPost 1) (FL.drainBy print)
37903791-- $ S.enumerateFrom 0
37913792-- @
37923793--
@@ -3797,13 +3798,14 @@ tapAsync f xs = D.fromStreamD $ D.tapAsync f (D.toStreamD xs)
37973798{-# INLINE pollCounts #-}
37983799pollCounts ::
37993800 (IsStream t, MonadAsync m)
3800− => (t m Int -> t m Int)
3801+ => (a -> Bool)
3802+ -> (t m Int -> t m Int)
38013803 -> Fold m Int b
38023804 -> t m a
38033805 -> t m a
3804−pollCounts transf f xs =
3806+pollCounts predicate transf f xs =
38053807 D.fromStreamD
3806− $ D.pollCounts (D.toStreamD . transf . D.fromStreamD) f
3808+ $ D.pollCounts predicate (D.toStreamD . transf . D.fromStreamD) f
38073809 $ (D.toStreamD xs)
38083810
38093811-- | Calls the supplied function with the number of elements consumed