@@ -92,7 +92,7 @@ module Streamly.Internal.Data.Stream.Concurrent
93 -- ** Reactive
93 -- ** Reactive
94 , fromCallback
94 , fromCallback
95− , tapCountD
95+ , parTapCount
96 , tapCount
96 , tapCount
@@ -726,14 +726,30 @@ fromCallback setCallback = Stream.concatEffect $ do
726 setCallback callback
726 setCallback callback
727 return stream
727 return stream
729+-- | @parTapCount predicate fold stream@ taps the count of those elements in
730+-- the stream that pass the @predicate@. The resulting count stream is sent to
731+-- a @fold@ running concurrently in another thread.
733+-- For example, to print the count of elements processed every second:
735+-- >>> rate = Stream.rollingMap2 (flip (-)) . Stream.delayPost 1
736+-- >>> report = Stream.fold (Fold.drainMapM print) . rate
737+-- >>> tap = Stream.parTapCount (const True) report
738+-- >>> go = Stream.fold Fold.drain $ tap $ Stream.enumerateFrom 0
740+-- Note: This may not work correctly on 32-bit machines because of Int
729−{-# INLINE_NORMAL tapCountD #-}
745+{-# INLINE_NORMAL parTapCount #-}
730−tapCountD
746+parTapCount
731 :: MonadAsync m
747 :: MonadAsync m
732 => (a -> Bool)
748 => (a -> Bool)
733 -> (D.Stream m Int -> m b)
749 -> (D.Stream m Int -> m b)
734 -> D.Stream m a
750 -> D.Stream m a
735 -> D.Stream m a
751 -> D.Stream m a
736−tapCountD predicate fld (D.Stream step state) = D.Stream step' Nothing
752+parTapCount predicate fld (D.Stream step state) = D.Stream step' Nothing
739 {-# INLINE_LATE step' #-}
755 {-# INLINE_LATE step' #-}
@@ -759,22 +775,9 @@ tapCountD predicate fld (D.Stream step state) = D.Stream step' Nothing
759 liftIO $ killThread tid
775 liftIO $ killThread tid
760 return Stop
776 return Stop
762−-- | @tapCount predicate fold stream@ taps the count of those elements in the
763−-- stream that pass the @predicate@. The resulting count stream is sent to
764−-- another thread which folds it using @fold@.
766−-- For example, to print the count of elements processed every second:
768−-- >>> rate = Stream.rollingMap2 (flip (-)) . Stream.delayPost 1
769−-- >>> report = Stream.fold (Fold.drainMapM print) . rate
770−-- >>> tap = Stream.tapCount (const True) report
771−-- >>> go = Stream.fold Fold.drain $ tap $ Stream.enumerateFrom 0
773−-- Note: This may not work correctly on 32-bit machines because of Int
776−-- /Pre-release/
778+-- Deprecate in a major release.
777−--
779+-- {-# DEPRECATED tapCount "Please use parTapCount instead." #-}
780+-- | Same as 'parTapCount'. Deprecated.
778{-# INLINE tapCount #-}
781{-# INLINE tapCount #-}
779tapCount ::
782tapCount ::
780 (MonadAsync m)
783 (MonadAsync m)
@@ -782,4 +785,4 @@ tapCount ::
782 -> (Stream m Int -> m b)
785 -> (Stream m Int -> m b)
783 -> Stream m a
786 -> Stream m a
784 -> Stream m a
787 -> Stream m a
785−tapCount = tapCountD
788+tapCount = parTapCount