@@ -23,15 +23,14 @@ import Data.IntMap.Strict (IntMap)
23import Data.Monoid (Last(..), Sum(..))
23import Data.Monoid (Last(..), Sum(..))
24import System.Random (randomRIO)
24import System.Random (randomRIO)
26−import Streamly.Prelude (SerialT)
26+import Streamly.Internal.Data.Stream (Stream)
27import Streamly.Internal.Data.Fold (Fold(..))
27import Streamly.Internal.Data.Fold (Fold(..))
28import Streamly.Internal.Data.IsMap.HashMap ()
28import Streamly.Internal.Data.IsMap.HashMap ()
30import qualified Streamly.Internal.Data.Fold as FL
30import qualified Streamly.Internal.Data.Fold as FL
31import qualified Streamly.Internal.Data.Unfold as Unfold
31import qualified Streamly.Internal.Data.Unfold as Unfold
32import qualified Streamly.Internal.Data.Pipe as Pipe
32import qualified Streamly.Internal.Data.Pipe as Pipe
33−import qualified Streamly.Internal.Data.Stream.IsStream as IP
33+import qualified Streamly.Internal.Data.Stream as Stream
34−import qualified Streamly.Prelude as S
36import Gauge
35import Gauge
37import Streamly.Benchmark.Common
36import Streamly.Benchmark.Common
@@ -41,8 +40,8 @@ import Prelude hiding (all, any, take, unzip, sequence_, filter)
41-- completely optimized out by the compiler in some cases.
40-- completely optimized out by the compiler in some cases.
43{-# INLINE sourceUnfoldrM #-}
42{-# INLINE sourceUnfoldrM #-}
44−sourceUnfoldrM :: (S.IsStream t, S.MonadAsync m) => Int -> Int -> t m Int
43+sourceUnfoldrM :: Monad m => Int -> Int -> Stream m Int
45−sourceUnfoldrM value n = S.unfoldrM step n
44+sourceUnfoldrM value n = Stream.unfoldrM step n
47 step cnt =
46 step cnt =
48 if cnt > n + value
47 if cnt > n + value
@@ -50,14 +49,14 @@ sourceUnfoldrM value n = S.unfoldrM step n
50 else return (Just (cnt, cnt + 1))
49 else return (Just (cnt, cnt + 1))
52{-# INLINE source #-}
51{-# INLINE source #-}
53−source :: (S.MonadAsync m, S.IsStream t) => Int -> Int -> t m Int
52+source :: Monad m => Int -> Int -> Stream m Int
54source = sourceUnfoldrM
53source = sourceUnfoldrM
56-- | Takes a fold method, and uses it with a default source.
55-- | Takes a fold method, and uses it with a default source.
57{-# INLINE benchIOSink #-}
56{-# INLINE benchIOSink #-}
58benchIOSink
57benchIOSink
59− :: (S.IsStream t, NFData b)
58+ :: NFData b
60− => Int -> String -> (t IO Int -> IO b) -> Benchmark
59+ => Int -> String -> (Stream IO Int -> IO b) -> Benchmark
61benchIOSink value name f = bench name $ nfIO $ randomRIO (1,1) >>= f . source value
60benchIOSink value name f = bench name $ nfIO $ randomRIO (1,1) >>= f . source value
63-------------------------------------------------------------------------------
62-------------------------------------------------------------------------------
@@ -65,16 +64,16 @@ benchIOSink value name f = bench name $ nfIO $ randomRIO (1,1) >>= f . source va
65-------------------------------------------------------------------------------
64-------------------------------------------------------------------------------
67{-# INLINE any #-}
66{-# INLINE any #-}
68−any :: (Monad m, Ord a) => a -> SerialT m a -> m Bool
67+any :: (Monad m, Ord a) => a -> Stream m a -> m Bool
69−any value = IP.fold (FL.any (> value))
68+any value = Stream.fold (FL.any (> value))
71{-# INLINE all #-}
70{-# INLINE all #-}
72−all :: (Monad m, Ord a) => a -> SerialT m a -> m Bool
71+all :: (Monad m, Ord a) => a -> Stream m a -> m Bool
73−all value = IP.fold (FL.all (<= value))
72+all value = Stream.fold (FL.all (<= value))
75{-# INLINE take #-}
74{-# INLINE take #-}
76−take :: Monad m => Int -> SerialT m a -> m ()
75+take :: Monad m => Int -> Stream m a -> m ()
77−take value = IP.fold (FL.take value FL.drain)
76+take value = Stream.fold (FL.take value FL.drain)
79{-# INLINE sequence_ #-}
78{-# INLINE sequence_ #-}
80sequence_ :: Monad m => Int -> Fold m a ()
79sequence_ :: Monad m => Int -> Fold m a ()
@@ -91,17 +90,17 @@ sequence_ value =
91-------------------------------------------------------------------------------
90-------------------------------------------------------------------------------
93{-# INLINE filter #-}
92{-# INLINE filter #-}
94−filter :: Monad m => Int -> SerialT m Int -> m ()
93+filter :: Monad m => Int -> Stream m Int -> m ()
95−filter _ = IP.fold (FL.filter even FL.drain)
94+filter _ = Stream.fold (FL.filter even FL.drain)
97{-# INLINE foldFilter #-}
96{-# INLINE foldFilter #-}
98−foldFilter :: Monad m => Int -> SerialT m Int -> m ()
97+foldFilter :: Monad m => Int -> Stream m Int -> m ()
99−foldFilter _ = IP.fold (FL.foldFilter (FL.satisfy even) FL.drain)
98+foldFilter _ = Stream.fold (FL.foldFilter (FL.satisfy even) FL.drain)
101{-# INLINE foldFilter2 #-}
100{-# INLINE foldFilter2 #-}
102−foldFilter2 :: Monad m => Int -> SerialT m Int -> m ()
101+foldFilter2 :: Monad m => Int -> Stream m Int -> m ()
103foldFilter2 _ =
102foldFilter2 _ =
104− IP.fold
103+ Stream.fold
105 $ FL.foldFilter (FL.satisfy even)
104 $ FL.foldFilter (FL.satisfy even)
106 $ FL.foldFilter (FL.satisfy odd) FL.drain
105 $ FL.foldFilter (FL.satisfy odd) FL.drain
@@ -110,43 +109,43 @@ foldFilter2 _ =
110-------------------------------------------------------------------------------
109-------------------------------------------------------------------------------
112{-# INLINE takeEndBy_ #-}
111{-# INLINE takeEndBy_ #-}
113−takeEndBy_ :: Monad m => Int -> SerialT m Int -> m ()
112+takeEndBy_ :: Monad m => Int -> Stream m Int -> m ()
114−takeEndBy_ value = IP.fold (FL.takeEndBy_ (>= value) FL.drain)
113+takeEndBy_ value = Stream.fold (FL.takeEndBy_ (>= value) FL.drain)
116{-# INLINE many #-}
115{-# INLINE many #-}
117−many :: Monad m => SerialT m Int -> m ()
116+many :: Monad m => Stream m Int -> m ()
118−many = IP.fold (FL.many (FL.take 1 FL.drain) FL.drain)
117+many = Stream.fold (FL.many (FL.take 1 FL.drain) FL.drain)
120{-# INLINE splitAllAny #-}
119{-# INLINE splitAllAny #-}
121−splitAllAny :: Monad m => Int -> SerialT m Int -> m (Bool, Bool)
120+splitAllAny :: Monad m => Int -> Stream m Int -> m (Bool, Bool)
122splitAllAny value =
121splitAllAny value =
123− IP.fold
122+ Stream.fold
124 (FL.serialWith (,)
123 (FL.serialWith (,)
125 (FL.all (<= (value `div` 2)))
124 (FL.all (<= (value `div` 2)))
126 (FL.any (> value))
125 (FL.any (> value))
129{-# INLINE serial_ #-}
128{-# INLINE serial_ #-}
130−serial_ :: Monad m => Int -> SerialT m Int -> m Bool
129+serial_ :: Monad m => Int -> Stream m Int -> m Bool
131serial_ value =
130serial_ value =
132− IP.fold
131+ Stream.fold
133 (FL.serial_
132 (FL.serial_
134 (FL.all (<= (value `div` 2)))
133 (FL.all (<= (value `div` 2)))
135 (FL.any (> value))
134 (FL.any (> value))
138{-# INLINE shortest #-}
137{-# INLINE shortest #-}
139−shortest :: Monad m => SerialT m Int -> m (Either Int Int)
138+shortest :: Monad m => Stream m Int -> m (Either Int Int)
140−shortest = IP.fold (FL.shortest FL.sum FL.length)
139+shortest = Stream.fold (FL.shortest FL.sum FL.length)
142{-# INLINE longest #-}
141{-# INLINE longest #-}
143−longest :: Monad m => SerialT m Int -> m (Either Int Int)
142+longest :: Monad m => Stream m Int -> m (Either Int Int)
144−longest = IP.fold (FL.longest FL.sum FL.length)
143+longest = Stream.fold (FL.longest FL.sum FL.length)
146{-# INLINE foldBreak #-}
145{-# INLINE foldBreak #-}
147−foldBreak :: Monad m => SerialT m Int -> m ()
146+foldBreak :: Monad m => Stream m Int -> m ()
148foldBreak s = do
147foldBreak s = do
149− (r, s1) <- IP.foldBreak (FL.take 1 FL.length) s
148+ (r, s1) <- Stream.foldBreak (FL.take 1 FL.length) s
150 when (r /= 0) $ foldBreak s1
149 when (r /= 0) $ foldBreak s1
152-------------------------------------------------------------------------------
151-------------------------------------------------------------------------------
@@ -154,12 +153,12 @@ foldBreak s = do
154-------------------------------------------------------------------------------
153-------------------------------------------------------------------------------
156{-# INLINE teeSumLength #-}
155{-# INLINE teeSumLength #-}
157−teeSumLength :: Monad m => SerialT m Int -> m (Int, Int)
156+teeSumLength :: Monad m => Stream m Int -> m (Int, Int)
158−teeSumLength = IP.fold (FL.teeWith (,) FL.sum FL.length)
157+teeSumLength = Stream.fold (FL.teeWith (,) FL.sum FL.length)
160{-# INLINE teeAllAny #-}
159{-# INLINE teeAllAny #-}
161−teeAllAny :: (Monad m, Ord a) => a -> SerialT m a -> m (Bool, Bool)
160+teeAllAny :: (Monad m, Ord a) => a -> Stream m a -> m (Bool, Bool)
162−teeAllAny value = IP.fold (FL.teeWith (,) all_ any_)
161+teeAllAny value = Stream.fold (FL.teeWith (,) all_ any_)
@@ -167,16 +166,16 @@ teeAllAny value = IP.fold (FL.teeWith (,) all_ any_)
167 any_ = FL.any (> value)
166 any_ = FL.any (> value)
169{-# INLINE teeWithFst #-}
168{-# INLINE teeWithFst #-}
170−teeWithFst :: Monad m => SerialT m Int -> m (Int, Int)
169+teeWithFst :: Monad m => Stream m Int -> m (Int, Int)
171−teeWithFst = IP.fold (FL.teeWithFst (,) FL.sum FL.length)
170+teeWithFst = Stream.fold (FL.teeWithFst (,) FL.sum FL.length)
173{-# INLINE teeWithMin #-}
172{-# INLINE teeWithMin #-}
174−teeWithMin :: Monad m => SerialT m Int -> m (Int, Int)
173+teeWithMin :: Monad m => Stream m Int -> m (Int, Int)
175−teeWithMin = IP.fold (FL.teeWithMin (,) FL.sum FL.length)
174+teeWithMin = Stream.fold (FL.teeWithMin (,) FL.sum FL.length)
177{-# INLINE distribute #-}
176{-# INLINE distribute #-}
178−distribute :: Monad m => SerialT m Int -> m [Int]
177+distribute :: Monad m => Stream m Int -> m [Int]
179−distribute = IP.fold (FL.distribute [FL.sum, FL.length])
178+distribute = Stream.fold (FL.distribute [FL.sum, FL.length])
181-------------------------------------------------------------------------------
180-------------------------------------------------------------------------------
182-- Partitioning
181-- Partitioning
@@ -187,88 +186,88 @@ oddEven :: Int -> Either Int Int
187oddEven x = if odd x then Left x else Right x
186oddEven x = if odd x then Left x else Right x
189{-# INLINE partition #-}
188{-# INLINE partition #-}
190−partition :: Monad m => SerialT m Int -> m (Int, Int)
189+partition :: Monad m => Stream m Int -> m (Int, Int)
191−partition = IP.fold $ FL.lmap oddEven (FL.partition FL.sum FL.length)
190+partition = Stream.fold $ FL.lmap oddEven (FL.partition FL.sum FL.length)
193{-# INLINE partitionByFstM #-}
192{-# INLINE partitionByFstM #-}
194−partitionByFstM :: Monad m => SerialT m Int -> m (Int, Int)
193+partitionByFstM :: Monad m => Stream m Int -> m (Int, Int)
195partitionByFstM =
194partitionByFstM =
196− IP.fold (FL.partitionByFstM (return . oddEven) FL.sum FL.length)
195+ Stream.fold (FL.partitionByFstM (return . oddEven) FL.sum FL.length)
198{-# INLINE partitionByMinM #-}
197{-# INLINE partitionByMinM #-}
199−partitionByMinM :: Monad m => SerialT m Int -> m (Int, Int)
198+partitionByMinM :: Monad m => Stream m Int -> m (Int, Int)
200partitionByMinM =
199partitionByMinM =
201− IP.fold (FL.partitionByMinM (return . oddEven) FL.sum FL.length)
200+ Stream.fold (FL.partitionByMinM (return . oddEven) FL.sum FL.length)
203{-# INLINE demuxWith #-}
202{-# INLINE demuxWith #-}
204demuxWith :: (Monad m, Ord k) =>
203demuxWith :: (Monad m, Ord k) =>
205− (a -> k) -> (a -> m (Fold m a b)) -> SerialT m a -> m (Map k b)
204+ (a -> k) -> (a -> m (Fold m a b)) -> Stream m a -> m (Map k b)
206−demuxWith f g = S.fold (FL.demuxWith f g)
205+demuxWith f g = Stream.fold (FL.demuxWith f g)
208{-# INLINE demuxWithInt #-}
207{-# INLINE demuxWithInt #-}
209demuxWithInt :: Monad m =>
208demuxWithInt :: Monad m =>
210− (a -> Int) -> (a -> m (Fold m a b)) -> SerialT m a -> m (IntMap b)
209+ (a -> Int) -> (a -> m (Fold m a b)) -> Stream m a -> m (IntMap b)
211−demuxWithInt f g = S.fold (FL.demuxWith f g)
210+demuxWithInt f g = Stream.fold (FL.demuxWith f g)
213{-# INLINE demuxWithHash #-}
212{-# INLINE demuxWithHash #-}
214demuxWithHash :: (Monad m, Ord k, Hashable k) =>
213demuxWithHash :: (Monad m, Ord k, Hashable k) =>
215− (a -> k) -> (a -> m (Fold m a b)) -> SerialT m a -> m (HashMap k b)
214+ (a -> k) -> (a -> m (Fold m a b)) -> Stream m a -> m (HashMap k b)
216−demuxWithHash f g = S.fold (FL.demuxWith f g)
215+demuxWithHash f g = Stream.fold (FL.demuxWith f g)
218{-# INLINE demuxMutWith #-}
217{-# INLINE demuxMutWith #-}
219demuxMutWith :: (MonadIO m, Ord k) =>
218demuxMutWith :: (MonadIO m, Ord k) =>
220− (a -> k) -> (a -> m (Fold m a b)) -> SerialT m a -> m (Map k b)
219+ (a -> k) -> (a -> m (Fold m a b)) -> Stream m a -> m (Map k b)
221−demuxMutWith f g = S.fold (FL.demuxMutWith f g)
220+demuxMutWith f g = Stream.fold (FL.demuxMutWith f g)
223{-# INLINE demuxMutWithHash #-}
222{-# INLINE demuxMutWithHash #-}
224demuxMutWithHash :: (MonadIO m, Ord k, Hashable k) =>
223demuxMutWithHash :: (MonadIO m, Ord k, Hashable k) =>
225− (a -> k) -> (a -> m (Fold m a b)) -> SerialT m a -> m (HashMap k b)
224+ (a -> k) -> (a -> m (Fold m a b)) -> Stream m a -> m (HashMap k b)
226−demuxMutWithHash f g = S.fold (FL.demuxMutWith f g)
225+demuxMutWithHash f g = Stream.fold (FL.demuxMutWith f g)
228{-# INLINE classifyWith #-}
227{-# INLINE classifyWith #-}
229classifyWith ::
228classifyWith ::
230− (Monad m, Ord k, Num a) => (a -> k) -> SerialT m a -> m (Map k a)
229+ (Monad m, Ord k, Num a) => (a -> k) -> Stream m a -> m (Map k a)
231−classifyWith f = S.fold (FL.classifyWith f FL.sum)
230+classifyWith f = Stream.fold (FL.classifyWith f FL.sum)
233{-# INLINE classifyWithInt #-}
232{-# INLINE classifyWithInt #-}
234classifyWithInt ::
233classifyWithInt ::
235− (MonadIO m, Num a) => (a -> Int) -> SerialT m a -> m (IntMap a)
234+ (Monad m, Num a) => (a -> Int) -> Stream m a -> m (IntMap a)
236−classifyWithInt f = S.fold (FL.classifyWith f FL.sum)
235+classifyWithInt f = Stream.fold (FL.classifyWith f FL.sum)
238{-# INLINE classifyMutWith #-}
237{-# INLINE classifyMutWith #-}
239classifyMutWith ::
238classifyMutWith ::
240− (MonadIO m, Ord k, Num a) => (a -> k) -> SerialT m a -> m (Map k a)
239+ (MonadIO m, Ord k, Num a) => (a -> k) -> Stream m a -> m (Map k a)
241−classifyMutWith f = S.fold (FL.classifyMutWith f FL.sum)
240+classifyMutWith f = Stream.fold (FL.classifyMutWith f FL.sum)
243{-# INLINE classifyMutWithInt #-}
242{-# INLINE classifyMutWithInt #-}
244classifyMutWithInt ::
243classifyMutWithInt ::
245− (MonadIO m, Num a) => (a -> Int) -> SerialT m a -> m (IntMap a)
244+ (MonadIO m, Num a) => (a -> Int) -> Stream m a -> m (IntMap a)
246−classifyMutWithInt f = S.fold (FL.classifyMutWith f FL.sum)
245+classifyMutWithInt f = Stream.fold (FL.classifyMutWith f FL.sum)
248{-# INLINE classifyMutWithHash #-}
247{-# INLINE classifyMutWithHash #-}
249classifyMutWithHash :: (MonadIO m, Ord k, Num a, Hashable k) =>
248classifyMutWithHash :: (MonadIO m, Ord k, Num a, Hashable k) =>
250− (a -> k) -> SerialT m a -> m (HashMap k a)
249+ (a -> k) -> Stream m a -> m (HashMap k a)
251−classifyMutWithHash f = S.fold (FL.classifyMutWith f FL.sum)
250+classifyMutWithHash f = Stream.fold (FL.classifyMutWith f FL.sum)
253-------------------------------------------------------------------------------
252-------------------------------------------------------------------------------
255-------------------------------------------------------------------------------
254-------------------------------------------------------------------------------
257{-# INLINE unzip #-}
256{-# INLINE unzip #-}
258−unzip :: Monad m => SerialT m Int -> m (Int, Int)
257+unzip :: Monad m => Stream m Int -> m (Int, Int)
259−unzip = IP.fold $ FL.lmap (\a -> (a, a)) (FL.unzip FL.sum FL.length)
258+unzip = Stream.fold $ FL.lmap (\a -> (a, a)) (FL.unzip FL.sum FL.length)
261{-# INLINE unzipWithFstM #-}
260{-# INLINE unzipWithFstM #-}
262−unzipWithFstM :: Monad m => SerialT m Int -> m (Int, Int)
261+unzipWithFstM :: Monad m => Stream m Int -> m (Int, Int)
263unzipWithFstM = do
262unzipWithFstM = do
264 let f = \a -> return (a + 1, a)
263 let f = \a -> return (a + 1, a)
265− IP.fold (FL.unzipWithFstM f FL.sum FL.length)
264+ Stream.fold (FL.unzipWithFstM f FL.sum FL.length)
267{-# INLINE unzipWithMinM #-}
266{-# INLINE unzipWithMinM #-}
268−unzipWithMinM :: Monad m => SerialT m Int -> m (Int, Int)
267+unzipWithMinM :: Monad m => Stream m Int -> m (Int, Int)
269unzipWithMinM = do
268unzipWithMinM = do
270 let f = \a -> return (a + 1, a)
269 let f = \a -> return (a + 1, a)
271− IP.fold (FL.unzipWithMinM f FL.sum FL.length)
270+ Stream.fold (FL.unzipWithMinM f FL.sum FL.length)
273-------------------------------------------------------------------------------
272-------------------------------------------------------------------------------
@@ -278,8 +277,8 @@ unzipWithMinM = do
278unfoldMany :: Int -> Benchmarkable
277unfoldMany :: Int -> Benchmarkable
279unfoldMany val =
278unfoldMany val =
281− $ IP.fold (FL.unfoldMany (Unfold.replicateM val) FL.drain)
280+ $ Stream.fold (FL.unfoldMany (Unfold.replicateM val) FL.drain)
282− $ IP.fromPure (randomRIO (1, 1 :: Int))
281+ $ Stream.fromPure (randomRIO (1, 1 :: Int))
284-------------------------------------------------------------------------------
283-------------------------------------------------------------------------------
285-- Benchmarks
284-- Benchmarks
@@ -291,103 +290,103 @@ moduleName = "Data.Fold"
291o_1_space_serial_elimination :: Int -> [Benchmark]
290o_1_space_serial_elimination :: Int -> [Benchmark]
292o_1_space_serial_elimination value =
291o_1_space_serial_elimination value =
293 [ bgroup "elimination"
292 [ bgroup "elimination"
294− [ benchIOSink value "drain" (S.fold FL.drain)
293+ [ benchIOSink value "drain" (Stream.fold FL.drain)
295− , benchIOSink value "drainBy" (S.fold (FL.drainBy return))
294+ , benchIOSink value "drainBy" (Stream.fold (FL.drainBy return))
296− , benchIOSink value "drainN" (S.fold (FL.drainN value))
295+ , benchIOSink value "drainN" (Stream.fold (FL.drainN value))
297− , benchIOSink value "last" (S.fold FL.last)
296+ , benchIOSink value "last" (Stream.fold FL.last)
298− , benchIOSink value "nub" (S.fold FL.nub)
297+ , benchIOSink value "nub" (Stream.fold FL.nub)
299− , benchIOSink value "length" (S.fold FL.length)
298+ , benchIOSink value "length" (Stream.fold FL.length)
300− , benchIOSink value "top" (S.fold $ FL.top 10)
299+ , benchIOSink value "top" (Stream.fold $ FL.top 10)
301− , benchIOSink value "bottom" (S.fold $ FL.bottom 10)
300+ , benchIOSink value "bottom" (Stream.fold $ FL.bottom 10)
302− , benchIOSink value "sum" (S.fold FL.sum)
301+ , benchIOSink value "sum" (Stream.fold FL.sum)
303− , benchIOSink value "sum (foldMap)" (S.fold (FL.foldMap Sum))
302+ , benchIOSink value "sum (foldMap)" (Stream.fold (FL.foldMap Sum))
304− , benchIOSink value "product" (S.fold FL.product)
303+ , benchIOSink value "product" (Stream.fold FL.product)
305− , benchIOSink value "maximumBy" (S.fold (FL.maximumBy compare))
304+ , benchIOSink value "maximumBy" (Stream.fold (FL.maximumBy compare))
306− , benchIOSink value "maximum" (S.fold FL.maximum)
305+ , benchIOSink value "maximum" (Stream.fold FL.maximum)
307− , benchIOSink value "minimumBy" (S.fold (FL.minimumBy compare))
306+ , benchIOSink value "minimumBy" (Stream.fold (FL.minimumBy compare))
308− , benchIOSink value "minimum" (S.fold FL.minimum)
307+ , benchIOSink value "minimum" (Stream.fold FL.minimum)
309 , benchIOSink
308 , benchIOSink
312− (S.fold FL.mean . S.map (fromIntegral :: Int -> Double))
311+ (Stream.fold FL.mean . fmap (fromIntegral :: Int -> Double))
313 , benchIOSink
312 , benchIOSink
315 "variance"
314 "variance"
316− (S.fold FL.variance . S.map (fromIntegral :: Int -> Double))
315+ (Stream.fold FL.variance . fmap (fromIntegral :: Int -> Double))
317 , benchIOSink
316 , benchIOSink
320− (S.fold FL.stdDev . S.map (fromIntegral :: Int -> Double))
319+ (Stream.fold FL.stdDev . fmap (fromIntegral :: Int -> Double))
321 , benchIOSink
320 , benchIOSink
323 "mconcat"
322 "mconcat"
324− (S.fold FL.mconcat . S.map (Last . Just))
323+ (Stream.fold FL.mconcat . fmap (Last . Just))
325 , benchIOSink
324 , benchIOSink
327 "foldMap"
326 "foldMap"
328− (S.fold (FL.foldMap (Last . Just)))
327+ (Stream.fold (FL.foldMap (Last . Just)))
329 , benchIOSink
328 , benchIOSink
331 "foldMapM"
330 "foldMapM"
332− (S.fold (FL.foldMapM (return . Last . Just)))
331+ (Stream.fold (FL.foldMapM (return . Last . Just)))
333− , benchIOSink value "index" (S.fold (FL.index (value + 1)))
332+ , benchIOSink value "index" (Stream.fold (FL.index (value + 1)))
334− , benchIOSink value "head" (S.fold FL.head)
333+ , benchIOSink value "head" (Stream.fold FL.head)
335− , benchIOSink value "find" (S.fold (FL.find (== (value + 1))))
334+ , benchIOSink value "find" (Stream.fold (FL.find (== (value + 1))))
336 , benchIOSink
335 , benchIOSink
339− (S.fold (FL.lmap (\a -> (a, a)) (FL.lookup (value + 1))))
338+ (Stream.fold (FL.lmap (\a -> (a, a)) (FL.lookup (value + 1))))
340 , benchIOSink
339 , benchIOSink
342 "findIndex"
341 "findIndex"
343− (S.fold (FL.findIndex (== (value + 1))))
342+ (Stream.fold (FL.findIndex (== (value + 1))))
344 , benchIOSink
343 , benchIOSink
346 "elemIndex"
345 "elemIndex"
347− (S.fold (FL.elemIndex (value + 1)))
346+ (Stream.fold (FL.elemIndex (value + 1)))
348− , benchIOSink value "null" (S.fold FL.null)
347+ , benchIOSink value "null" (Stream.fold FL.null)
349− , benchIOSink value "elem" (S.fold (FL.elem (value + 1)))
348+ , benchIOSink value "elem" (Stream.fold (FL.elem (value + 1)))
350− , benchIOSink value "notElem" (S.fold (FL.notElem (value + 1)))
349+ , benchIOSink value "notElem" (Stream.fold (FL.notElem (value + 1)))
351 , benchIOSink value "all" $ all value
350 , benchIOSink value "all" $ all value
352 , benchIOSink value "any" $ any value
351 , benchIOSink value "any" $ any value
353 , benchIOSink value "take" $ take value
352 , benchIOSink value "take" $ take value
354 , benchIOSink value "takeEndBy_" $ takeEndBy_ value
353 , benchIOSink value "takeEndBy_" $ takeEndBy_ value
355− , benchIOSink value "and" (S.fold FL.and . S.map (<= (value + 1)))
354+ , benchIOSink value "and" (Stream.fold FL.and . fmap (<= (value + 1)))
356− , benchIOSink value "or" (S.fold FL.or . S.map (> (value + 1)))
355+ , benchIOSink value "or" (Stream.fold FL.or . fmap (> (value + 1)))
360o_1_space_serial_transformation :: Int -> [Benchmark]
359o_1_space_serial_transformation :: Int -> [Benchmark]
361o_1_space_serial_transformation value =
360o_1_space_serial_transformation value =
362 [ bgroup "transformation"
361 [ bgroup "transformation"
363− [ benchIOSink value "map" (S.fold (FL.lmap (+ 1) FL.drain))
362+ [ benchIOSink value "map" (Stream.fold (FL.lmap (+ 1) FL.drain))
364 , let f x = if even x then Just x else Nothing
363 , let f x = if even x then Just x else Nothing
365 fld = FL.mapMaybe f FL.drain
364 fld = FL.mapMaybe f FL.drain
366− in benchIOSink value "mapMaybe" (S.fold fld)
365+ in benchIOSink value "mapMaybe" (Stream.fold fld)
367 , benchIOSink
366 , benchIOSink
369 "rsequence"
368 "rsequence"
370− (S.fold (FL.rmapM id (return <$> FL.drain)))
369+ (Stream.fold (FL.rmapM id (return <$> FL.drain)))
371− , benchIOSink value "rmapM" (S.fold (FL.rmapM return FL.drain))
370+ , benchIOSink value "rmapM" (Stream.fold (FL.rmapM return FL.drain))
372 , benchIOSink
371 , benchIOSink
374 "pipe-mapM"
373 "pipe-mapM"
375− (S.fold
374+ (Stream.fold
376 (FL.transform
375 (FL.transform
377 (Pipe.mapM (\x -> return $ x + 1))
376 (Pipe.mapM (\x -> return $ x + 1))
378 FL.drain))
377 FL.drain))
379 , benchIOSink
378 , benchIOSink
381 "fold-scan"
380 "fold-scan"
382− (S.fold $ FL.scan FL.sum FL.drain)
381+ (Stream.fold $ FL.scan FL.sum FL.drain)
383 , benchIOSink
382 , benchIOSink
385 "fold-scanMany"
384 "fold-scanMany"
386− (S.fold $ FL.scanMany (FL.take 2 FL.drain) FL.drain)
385+ (Stream.fold $ FL.scanMany (FL.take 2 FL.drain) FL.drain)
387 , benchIOSink
386 , benchIOSink
389 "fold-postscan"
388 "fold-postscan"
390− (S.fold $ FL.postscan FL.sum FL.drain)
389+ (Stream.fold $ FL.postscan FL.sum FL.drain)
@@ -421,7 +420,7 @@ o_1_space_serial_composition value =
422o_n_space_serial :: Int -> [Benchmark]
421o_n_space_serial :: Int -> [Benchmark]
423o_n_space_serial value =
422o_n_space_serial value =
424− [ benchIOSink value "sequence_/100" $ S.fold (sequence_ (value `div` 100))
423+ [ benchIOSink value "sequence_/100" $ Stream.fold (sequence_ (value `div` 100))
427o_n_heap_serial :: Int -> [Benchmark]
426o_n_heap_serial :: Int -> [Benchmark]
@@ -430,14 +429,14 @@ o_n_heap_serial value =
430 -- Left folds for building a structure are inherently non-streaming
429 -- Left folds for building a structure are inherently non-streaming
431 -- as the structure cannot be lazily consumed until fully built.
430 -- as the structure cannot be lazily consumed until fully built.
433− benchIOSink value "toList" (S.fold FL.toList)
432+ benchIOSink value "toList" (Stream.fold FL.toList)
434− , benchIOSink value "toListRev" (S.fold FL.toListRev)
433+ , benchIOSink value "toListRev" (Stream.fold FL.toListRev)
435 , benchIOSink value "toStream"
434 , benchIOSink value "toStream"
436− (S.fold FL.toStream
435+ (Stream.fold FL.toStream
437− :: SerialT IO a -> IO (SerialT Identity a))
436+ :: Stream IO a -> IO (Stream Identity a))
438 , benchIOSink value "toStreamRev"
437 , benchIOSink value "toStreamRev"
439− (S.fold FL.toStreamRev
438+ (Stream.fold FL.toStreamRev
440− :: SerialT IO a -> IO (SerialT Identity a))
439+ :: Stream IO a -> IO (Stream Identity a))
442 , bgroup "key-value"
441 , bgroup "key-value"