on master help sign in
Rename stream transformation some APIs
badc62dHarendra Kumar
benchmark/Streamly/Benchmark/Prelude/Serial/Transformation1.hs+15−15
@@ -303,14 +303,14 @@ takeWhileTrue value n = composeN n $ S.takeWhile (<= (value + 1))
303takeWhileMTrue :: MonadIO m => Int -> Int -> SerialT m Int -> m ()
303takeWhileMTrue :: MonadIO m => Int -> Int -> SerialT m Int -> m ()
304takeWhileMTrue value n = composeN n $ S.takeWhileM (return . (<= (value + 1)))
304takeWhileMTrue value n = composeN n $ S.takeWhileM (return . (<= (value + 1)))
305
305
306−{-# INLINE takeByTime #-}
306+{-# INLINE takeInterval #-}
307−takeByTime :: NanoSecond64 -> Int -> SerialT IO Int -> IO ()
307+takeInterval :: NanoSecond64 -> Int -> SerialT IO Int -> IO ()
308−takeByTime i n = composeN n (Internal.takeByTime i)
308+takeInterval i n = composeN n (Internal.takeInterval i)
309
309
310#ifdef INSPECTION
310#ifdef INSPECTION
311−-- inspect $ hasNoType 'takeByTime ''SPEC
311+-- inspect $ hasNoType 'takeInterval ''SPEC
312−inspect $ hasNoTypeClasses 'takeByTime
312+inspect $ hasNoTypeClasses 'takeInterval
313−-- inspect $ 'takeByTime `hasNoType` ''D.Step
313+-- inspect $ 'takeInterval `hasNoType` ''D.Step
314#endif
314#endif
315
315
316{-# INLINE dropOne #-}
316{-# INLINE dropOne #-}
@@ -338,13 +338,13 @@ dropWhileFalse value n = composeN n $ S.dropWhile (> (value + 1))
338_intervalsOfSum :: MonadAsync m => Double -> Int -> SerialT m Int -> m ()
338_intervalsOfSum :: MonadAsync m => Double -> Int -> SerialT m Int -> m ()
339_intervalsOfSum i n = composeN n (S.intervalsOf i FL.sum)
339_intervalsOfSum i n = composeN n (S.intervalsOf i FL.sum)
340
340
341−{-# INLINE dropByTime #-}
341+{-# INLINE dropInterval #-}
342−dropByTime :: NanoSecond64 -> Int -> SerialT IO Int -> IO ()
342+dropInterval :: NanoSecond64 -> Int -> SerialT IO Int -> IO ()
343−dropByTime i n = composeN n (Internal.dropByTime i)
343+dropInterval i n = composeN n (Internal.dropInterval i)
344
344
345#ifdef INSPECTION
345#ifdef INSPECTION
346−inspect $ hasNoTypeClasses 'dropByTime
346+inspect $ hasNoTypeClasses 'dropInterval
347−-- inspect $ 'dropByTime `hasNoType` ''D.Step
347+-- inspect $ 'dropInterval `hasNoType` ''D.Step
348#endif
348#endif
349
349
350{-# INLINE findIndices #-}
350{-# INLINE findIndices #-}
@@ -399,16 +399,16 @@ o_1_space_filtering value =
399 , benchIOSink value "take-all" (takeAll value 1)
399 , benchIOSink value "take-all" (takeAll value 1)
400 , benchIOSink
400 , benchIOSink
401 value
401 value
402− "takeByTime-all"
402+ "takeInterval-all"
403− (takeByTime (NanoSecond64 maxBound) 1)
403+ (takeInterval (NanoSecond64 maxBound) 1)
404 , benchIOSink value "takeWhile-true" (takeWhileTrue value 1)
404 , benchIOSink value "takeWhile-true" (takeWhileTrue value 1)
405 -- , benchIOSink value "takeWhileM-true" (_takeWhileMTrue value 1)
405 -- , benchIOSink value "takeWhileM-true" (_takeWhileMTrue value 1)
406 , benchIOSink value "drop-one" (dropOne 1)
406 , benchIOSink value "drop-one" (dropOne 1)
407 , benchIOSink value "drop-all" (dropAll value 1)
407 , benchIOSink value "drop-all" (dropAll value 1)
408 , benchIOSink
408 , benchIOSink
409 value
409 value
410− "dropByTime-all"
410+ "dropInterval-all"
411− (dropByTime (NanoSecond64 maxBound) 1)
411+ (dropInterval (NanoSecond64 maxBound) 1)
412 , benchIOSink value "dropWhile-true" (dropWhileTrue value 1)
412 , benchIOSink value "dropWhile-true" (dropWhileTrue value 1)
413 -- , benchIOSink value "dropWhileM-true" (_dropWhileMTrue value 1)
413 -- , benchIOSink value "dropWhileM-true" (_dropWhileMTrue value 1)
414 , benchIOSink
414 , benchIOSink
src/Streamly/Internal/Data/Stream/IsStream/Eliminate.hs−1
@@ -420,7 +420,6 @@ runN = drainN
420
420
421-- |
421-- |
422-- > drainWhile p = drain . takeWhile p
422-- > drainWhile p = drain . takeWhile p
423−-- > drainWhile p = fold (Fold.sliceSepBy (not . p) Fold.drain)
424--
423--
425-- Run a stream as long as the predicate holds true.
424-- Run a stream as long as the predicate holds true.
426--
425--
src/Streamly/Internal/Data/Stream/IsStream/Transform.hs+37−37
@@ -82,20 +82,20 @@ module Streamly.Internal.Data.Stream.IsStream.Transform
82 -- | Produce a subset of the stream trimmed at ends.
82 -- | Produce a subset of the stream trimmed at ends.
83
83
84 , take
84 , take
85− , takeByTime -- takeInterval
85+ , takeInterval
86− , takeEnd
86+ , takeLast
87− , takeEndInterval
87+ , takeLastInterval
88 , takeWhile
88 , takeWhile
89 , takeWhileM
89 , takeWhileM
90− , takeWhileEnd
90+ , takeWhileLast
91 , takeWhileAround
91 , takeWhileAround
92 , drop
92 , drop
93− , dropByTime -- dropInterval
93+ , dropInterval
94− , dropEnd
94+ , dropLast
95− , dropEndInterval
95+ , dropLastInterval
96 , dropWhile
96 , dropWhile
97 , dropWhileM
97 , dropWhileM
98− , dropWhileEnd
98+ , dropWhileLast
99 , dropWhileAround
99 , dropWhileAround
100
100
101 -- * Inserting Elements
101 -- * Inserting Elements
@@ -931,27 +931,27 @@ takeWhileM p m = fromStreamD $ D.takeWhileM p $ toStreamD m
931
931
932-- See the lastN fold for impl hints. Use a Data.Array based ring buffer.
932-- See the lastN fold for impl hints. Use a Data.Array based ring buffer.
933--
933--
934−-- takeEnd n = Stream.concatM . fmap Array.toStream . fold Fold.lastN
934+-- takeLast n = Stream.concatM . fmap Array.toStream . fold Fold.lastN
935--
935--
936-- | Take @n@ elements at the end of the stream.
936-- | Take @n@ elements at the end of the stream.
937--
937--
938-- O(n) space, where n is the number elements taken.
938-- O(n) space, where n is the number elements taken.
939--
939--
940-- /Unimplemented/
940-- /Unimplemented/
941−{-# INLINE takeEnd #-}
941+{-# INLINE takeLast #-}
942−takeEnd :: -- (IsStream t, Monad m) =>
942+takeLast :: -- (IsStream t, Monad m) =>
943 Int -> t m a -> t m a
943 Int -> t m a -> t m a
944−takeEnd = undefined -- fromStreamD $ D.takeEnd n $ toStreamD m
944+takeLast = undefined -- fromStreamD $ D.takeLast n $ toStreamD m
945
945
946-- | Take time interval @i@ seconds at the end of the stream.
946-- | Take time interval @i@ seconds at the end of the stream.
947--
947--
948-- O(n) space, where n is the number elements taken.
948-- O(n) space, where n is the number elements taken.
949--
949--
950-- /Unimplemented/
950-- /Unimplemented/
951−{-# INLINE takeEndInterval #-}
951+{-# INLINE takeLastInterval #-}
952−takeEndInterval :: -- (IsStream t, Monad m) =>
952+takeLastInterval :: -- (IsStream t, Monad m) =>
953 Double -> t m a -> t m a
953 Double -> t m a -> t m a
954−takeEndInterval = undefined -- fromStreamD $ D.takeEnd n $ toStreamD m
954+takeLastInterval = undefined -- fromStreamD $ D.takeLast n $ toStreamD m
955
955
956-- | Take all consecutive elements at the end of the stream for which the
956-- | Take all consecutive elements at the end of the stream for which the
957-- predicate is true.
957-- predicate is true.
@@ -959,12 +959,12 @@ takeEndInterval = undefined -- fromStreamD $ D.takeEnd n $ toStreamD m
959-- O(n) space, where n is the number elements taken.
959-- O(n) space, where n is the number elements taken.
960--
960--
961-- /Unimplemented/
961-- /Unimplemented/
962−{-# INLINE takeWhileEnd #-}
962+{-# INLINE takeWhileLast #-}
963−takeWhileEnd :: -- (IsStream t, Monad m) =>
963+takeWhileLast :: -- (IsStream t, Monad m) =>
964 (a -> Bool) -> t m a -> t m a
964 (a -> Bool) -> t m a -> t m a
965−takeWhileEnd = undefined -- fromStreamD $ D.takeWhileEnd n $ toStreamD m
965+takeWhileLast = undefined -- fromStreamD $ D.takeWhileLast n $ toStreamD m
966
966
967−-- | Like 'takeWhile' and 'takeWhileEnd' combined.
967+-- | Like 'takeWhile' and 'takeWhileLast' combined.
968--
968--
969-- O(n) space, where n is the number elements taken from the end.
969-- O(n) space, where n is the number elements taken from the end.
970--
970--
@@ -974,7 +974,7 @@ takeWhileAround :: -- (IsStream t, Monad m) =>
974 (a -> Bool) -> t m a -> t m a
974 (a -> Bool) -> t m a -> t m a
975takeWhileAround = undefined -- fromStreamD $ D.takeWhileAround n $ toStreamD m
975takeWhileAround = undefined -- fromStreamD $ D.takeWhileAround n $ toStreamD m
976
976
977−-- | @takeByTime duration@ yields stream elements upto specified time
977+-- | @takeInterval duration@ yields stream elements upto specified time
978-- @duration@. The duration starts when the stream is evaluated for the first
978-- @duration@. The duration starts when the stream is evaluated for the first
979-- time, before the first element is yielded. The time duration is checked
979-- time, before the first element is yielded. The time duration is checked
980-- before generating each element, if the duration has expired the stream
980-- before generating each element, if the duration has expired the stream
@@ -990,9 +990,9 @@ takeWhileAround = undefined -- fromStreamD $ D.takeWhileAround n $ toStreamD m
990--
990--
991-- /Pre-release/
991-- /Pre-release/
992--
992--
993−{-# INLINE takeByTime #-}
993+{-# INLINE takeInterval #-}
994−takeByTime ::(MonadIO m, IsStream t, TimeUnit64 d) => d -> t m a -> t m a
994+takeInterval ::(MonadIO m, IsStream t, TimeUnit64 d) => d -> t m a -> t m a
995−takeByTime d = fromStreamD . D.takeByTime d . toStreamD
995+takeInterval d = fromStreamD . D.takeByTime d . toStreamD
996
996
997-- | Drop elements in the stream as long as the predicate succeeds and then
997-- | Drop elements in the stream as long as the predicate succeeds and then
998-- take the rest of the stream.
998-- take the rest of the stream.
@@ -1009,7 +1009,7 @@ dropWhile p m = fromStreamS $ S.dropWhile p $ toStreamS m
1009dropWhileM :: (IsStream t, Monad m) => (a -> m Bool) -> t m a -> t m a
1009dropWhileM :: (IsStream t, Monad m) => (a -> m Bool) -> t m a -> t m a
1010dropWhileM p m = fromStreamD $ D.dropWhileM p $ toStreamD m
1010dropWhileM p m = fromStreamD $ D.dropWhileM p $ toStreamD m
1011
1011
1012−-- | @dropByTime duration@ drops stream elements until specified @duration@ has
1012+-- | @dropInterval duration@ drops stream elements until specified @duration@ has
1013-- passed. The duration begins when the stream is evaluated for the first
1013-- passed. The duration begins when the stream is evaluated for the first
1014-- time. The time duration is checked /after/ generating a stream element, the
1014-- time. The time duration is checked /after/ generating a stream element, the
1015-- element is yielded if the duration has expired otherwise it is dropped.
1015-- element is yielded if the duration has expired otherwise it is dropped.
@@ -1023,29 +1023,29 @@ dropWhileM p m = fromStreamD $ D.dropWhileM p $ toStreamD m
1023--
1023--
1024-- /Pre-release/
1024-- /Pre-release/
1025--
1025--
1026−{-# INLINE dropByTime #-}
1026+{-# INLINE dropInterval #-}
1027−dropByTime ::(MonadIO m, IsStream t, TimeUnit64 d) => d -> t m a -> t m a
1027+dropInterval ::(MonadIO m, IsStream t, TimeUnit64 d) => d -> t m a -> t m a
1028−dropByTime d = fromStreamD . D.dropByTime d . toStreamD
1028+dropInterval d = fromStreamD . D.dropByTime d . toStreamD
1029
1029
1030-- | Drop @n@ elements at the end of the stream.
1030-- | Drop @n@ elements at the end of the stream.
1031--
1031--
1032-- O(n) space, where n is the number elements dropped.
1032-- O(n) space, where n is the number elements dropped.
1033--
1033--
1034-- /Unimplemented/
1034-- /Unimplemented/
1035−{-# INLINE dropEnd #-}
1035+{-# INLINE dropLast #-}
1036−dropEnd :: -- (IsStream t, Monad m) =>
1036+dropLast :: -- (IsStream t, Monad m) =>
1037 Int -> t m a -> t m a
1037 Int -> t m a -> t m a
1038−dropEnd = undefined -- fromStreamD $ D.dropEnd n $ toStreamD m
1038+dropLast = undefined -- fromStreamD $ D.dropLast n $ toStreamD m
1039
1039
1040-- | Drop time interval @i@ seconds at the end of the stream.
1040-- | Drop time interval @i@ seconds at the end of the stream.
1041--
1041--
1042-- O(n) space, where n is the number elements dropped.
1042-- O(n) space, where n is the number elements dropped.
1043--
1043--
1044-- /Unimplemented/
1044-- /Unimplemented/
1045−{-# INLINE dropEndInterval #-}
1045+{-# INLINE dropLastInterval #-}
1046−dropEndInterval :: -- (IsStream t, Monad m) =>
1046+dropLastInterval :: -- (IsStream t, Monad m) =>
1047 Int -> t m a -> t m a
1047 Int -> t m a -> t m a
1048−dropEndInterval = undefined
1048+dropLastInterval = undefined
1049
1049
1050-- | Drop all consecutive elements at the end of the stream for which the
1050-- | Drop all consecutive elements at the end of the stream for which the
1051-- predicate is true.
1051-- predicate is true.
@@ -1053,12 +1053,12 @@ dropEndInterval = undefined
1053-- O(n) space, where n is the number elements dropped.
1053-- O(n) space, where n is the number elements dropped.
1054--
1054--
1055-- /Unimplemented/
1055-- /Unimplemented/
1056−{-# INLINE dropWhileEnd #-}
1056+{-# INLINE dropWhileLast #-}
1057−dropWhileEnd :: -- (IsStream t, Monad m) =>
1057+dropWhileLast :: -- (IsStream t, Monad m) =>
1058 (a -> Bool) -> t m a -> t m a
1058 (a -> Bool) -> t m a -> t m a
1059−dropWhileEnd = undefined -- fromStreamD $ D.dropWhileEnd n $ toStreamD m
1059+dropWhileLast = undefined -- fromStreamD $ D.dropWhileLast n $ toStreamD m
1060
1060
1061−-- | Like 'dropWhile' and 'dropWhileEnd' combined.
1061+-- | Like 'dropWhile' and 'dropWhileLast' combined.
1062--
1062--
1063-- O(n) space, where n is the number elements dropped from the end.
1063-- O(n) space, where n is the number elements dropped from the end.
1064--
1064--