on master help sign in
Rename tapCount to parTapCount
92b4094Harendra Kumar
src/Streamly/Data/Stream/Concurrent.hs+3
@@ -98,6 +98,9 @@ module Streamly.Data.Stream.Concurrent
98 , parConcatIterate
98 , parConcatIterate
99
99
100 -- *** Observation
100 -- *** Observation
101+ , parTapCount
102+
103+ -- ** Deprecated
101 , tapCount
104 , tapCount
102 )
105 )
103where
106where
src/Streamly/Internal/Data/Stream/Concurrent.hs+24−21
@@ -92,7 +92,7 @@ module Streamly.Internal.Data.Stream.Concurrent
92
92
93 -- ** Reactive
93 -- ** Reactive
94 , fromCallback
94 , fromCallback
95− , tapCountD
95+ , parTapCount
96 , tapCount
96 , tapCount
97 )
97 )
98where
98where
@@ -726,14 +726,30 @@ fromCallback setCallback = Stream.concatEffect $ do
726 setCallback callback
726 setCallback callback
727 return stream
727 return stream
728
728
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.
732+--
733+-- For example, to print the count of elements processed every second:
734+--
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
739+--
740+-- Note: This may not work correctly on 32-bit machines because of Int
741+-- overflow.
742+--
743+-- /Pre-release/
744+--
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
737 where
753 where
738
754
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
761
777
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@.
765−--
766−-- For example, to print the count of elements processed every second:
767−--
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
772−--
773−-- Note: This may not work correctly on 32-bit machines because of Int
774−-- overflow.
775−--
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
src/Streamly/Internal/Data/Stream/IsStream/Transform.hs+1−1
@@ -583,7 +583,7 @@ pollCounts ::
583 -> t m a
583 -> t m a
584pollCounts predicate f xs =
584pollCounts predicate f xs =
585 fromStreamD
585 fromStreamD
586− $ Concur.tapCountD predicate (f . fromStreamD)
586+ $ Concur.parTapCount predicate (f . fromStreamD)
587 $ toStreamD xs
587 $ toStreamD xs
588
588
589-- | Apply a monadic function to each element flowing through the stream and
589-- | Apply a monadic function to each element flowing through the stream and