on master help sign in
Use full module names in documentation
commitf95cb897e157519f5e4c54d12a9475033fdc5290 authorRanjeet Kumar Ranjan <ranjeetr@composewell.com> dateSun 30 May 2021, 21:19 (5 years ago) parent4ca4d31
6 files changed+163−100
src/Streamly/Internal/Data/Stream/IsStream/Enumeration.hs+49−24 src/Streamly/Internal/Data/Stream/IsStream/Expand.hs+15−13 src/Streamly/Internal/Data/Stream/IsStream/Generate.hs+12−12 src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+4−4 src/Streamly/Internal/Data/Stream/IsStream/Transform.hs+75−41 src/Streamly/Prelude.hs+8−6
src/Streamly/Internal/Data/Stream/IsStream/Enumeration.hs+49−24
@@ -78,10 +78,13 @@ import qualified Streamly.Internal.Data.Stream.Serial as Serial (map)
7878-- check for overflow, underflow or bounds.
7979--
8080-- @
81−-- > S.toList $ S.take 4 $ S.enumerateFromStepIntegral 0 2
81+-- >>> import Streamly.Internal.Data.Stream.IsStream.Enumeration as Stream
82+-- >>> Stream.toList $ Stream.take 4 $ Stream.enumerateFromStepIntegral 0 2
8283-- [0,2,4,6]
83−-- > S.toList $ S.take 3 $ S.enumerateFromStepIntegral 0 (-2)
84+--
85+-- >>> Stream.toList $ Stream.take 3 $ Stream.enumerateFromStepIntegral 0 (-2)
8486-- [0,-2,-4]
87+--
8588-- @
8689--
8790-- @since 0.6.0
@@ -97,8 +100,9 @@ enumerateFromStepIntegral from stride =
97100-- increments of @1@. The stream is bounded by the size of the 'Integral' type.
98101--
99102-- @
100−-- > S.toList $ S.take 4 $ S.enumerateFromIntegral (0 :: Int)
103+-- >>> Stream.toList $ Stream.take 4 $ Stream.enumerateFromIntegral (0 :: Int)
101104-- [0,1,2,3]
105+--
102106-- @
103107--
104108-- @since 0.6.0
@@ -114,10 +118,12 @@ enumerateFromIntegral from = fromStreamD $ D.enumerateFromIntegral from
114118-- The stream is bounded by the size of the 'Integral' type.
115119--
116120-- @
117−-- > S.toList $ S.take 4 $ S.enumerateFromThenIntegral (0 :: Int) 2
121+-- >>> Stream.toList $ Stream.take 4 $ Stream.enumerateFromThenIntegral (0 :: Int) 2
118122-- [0,2,4,6]
119−-- > S.toList $ S.take 4 $ S.enumerateFromThenIntegral (0 :: Int) (-2)
123+--
124+-- >>> Stream.toList $ Stream.take 4 $ Stream.enumerateFromThenIntegral (0 :: Int) (-2)
120125-- [0,-2,-4,-6]
126+--
121127-- @
122128--
123129-- @since 0.6.0
@@ -134,8 +140,9 @@ enumerateFromThenIntegral from next =
134140-- @to@.
135141--
136142-- @
137−-- > S.toList $ S.enumerateFromToIntegral 0 4
143+-- >>> Stream.toList $ Stream.enumerateFromToIntegral 0 4
138144-- [0,1,2,3,4]
145+--
139146-- @
140147--
141148-- @since 0.6.0
@@ -150,10 +157,12 @@ enumerateFromToIntegral from to =
150157-- elements are in increments of @then - from@ up to @to@.
151158--
152159-- @
153−-- > S.toList $ S.enumerateFromThenToIntegral 0 2 6
160+-- >>> Stream.toList $ Stream.enumerateFromThenToIntegral 0 2 6
154161-- [0,2,4,6]
155−-- > S.toList $ S.enumerateFromThenToIntegral 0 (-2) (-6)
162+--
163+-- >>> Stream.toList $ Stream.enumerateFromThenToIntegral 0 (-2) (-6)
156164-- [0,-2,-4,-6]
165+--
157166-- @
158167--
159168-- @since 0.6.0
@@ -181,8 +190,9 @@ enumerateFromThenToIntegral from next to =
181190-- This is the equivalent to 'enumFrom' for 'Fractional' types. For example:
182191--
183192-- @
184−-- > S.toList $ S.take 4 $ S.enumerateFromFractional 1.1
193+-- >>> Stream.toList $ Stream.take 4 $ Stream.enumerateFromFractional 1.1
185194-- [1.1,2.1,3.1,4.1]
195+--
186196-- @
187197--
188198--
@@ -201,10 +211,12 @@ enumerateFromFractional from = fromStreamD $ D.numFrom from
201211-- example:
202212--
203213-- @
204−-- > S.toList $ S.take 4 $ S.enumerateFromThenFractional 1.1 2.1
214+-- >>> Stream.toList $ Stream.take 4 $ Stream.enumerateFromThenFractional 1.1 2.1
205215-- [1.1,2.1,3.1,4.1]
206−-- > S.toList $ S.take 4 $ S.enumerateFromThenFractional 1.1 (-2.1)
216+--
217+-- >>> Stream.toList $ Stream.take 4 $ Stream.enumerateFromThenFractional 1.1 (-2.1)
207218-- [1.1,-2.1,-5.300000000000001,-8.500000000000002]
219+--
208220-- @
209221--
210222-- @since 0.6.0
@@ -223,10 +235,12 @@ enumerateFromThenFractional from next = fromStreamD $ D.numFromThen from next
223235-- example:
224236--
225237-- @
226−-- > S.toList $ S.enumerateFromToFractional 1.1 4
238+-- >>> Stream.toList $ Stream.enumerateFromToFractional 1.1 4
227239-- [1.1,2.1,3.1,4.1]
228−-- > S.toList $ S.enumerateFromToFractional 1.1 4.6
240+--
241+-- >>> Stream.toList $ Stream.enumerateFromToFractional 1.1 4.6
229242-- [1.1,2.1,3.1,4.1,5.1]
243+--
230244-- @
231245--
232246-- Notice that the last element is equal to the specified @to@ value after
@@ -249,10 +263,12 @@ enumerateFromToFractional from to =
249263-- example:
250264--
251265-- @
252−-- > S.toList $ S.enumerateFromThenToFractional 0.1 2 6
266+-- >>> Stream.toList $ Stream.enumerateFromThenToFractional 0.1 2 6
253267-- [0.1,2.0,3.9,5.799999999999999]
254−-- > S.toList $ S.enumerateFromThenToFractional 0.1 (-2) (-6)
268+--
269+-- >>> Stream.toList $ Stream.enumerateFromThenToFractional 0.1 (-2) (-6)
255270-- [0.1,-2.0,-4.1000000000000005,-6.200000000000001]
271+--
256272-- @
257273--
258274--
@@ -327,16 +343,18 @@ class Enum a => Enumerable a where
327343 -- generating an infinite stream when the type is not 'Bounded'.
328344 --
329345 -- @
330− -- > S.toList $ S.take 4 $ S.enumerateFrom (0 :: Int)
346+ -- >>> Stream.toList $ Stream.take 4 $ Stream.enumerateFrom (0 :: Int)
331347 -- [0,1,2,3]
348+ --
332349 -- @
333350 --
334351 -- For 'Fractional' types, enumeration is numerically stable. However, no
335352 -- overflow or underflow checks are performed.
336353 --
337354 -- @
338− -- > S.toList $ S.take 4 $ S.enumerateFrom 1.1
355+ -- >>> Stream.toList $ Stream.take 4 $ Stream.enumerateFrom 1.1
339356 -- [1.1,2.1,3.1,4.1]
357+ --
340358 -- @
341359 --
342360 -- @since 0.6.0
@@ -347,18 +365,21 @@ class Enum a => Enumerable a where
347365 -- empty stream is returned.
348366 --
349367 -- @
350− -- > S.toList $ S.enumerateFromTo 0 4
368+ -- >>> Stream.toList $ Stream.enumerateFromTo 0 4
351369 -- [0,1,2,3,4]
370+ --
352371 -- @
353372 --
354373 -- For 'Fractional' types, the last element is equal to the specified @to@
355374 -- value after rounding to the nearest integral value.
356375 --
357376 -- @
358− -- > S.toList $ S.enumerateFromTo 1.1 4
377+ -- >>> Stream.toList $ Stream.enumerateFromTo 1.1 4
359378 -- [1.1,2.1,3.1,4.1]
360− -- > S.toList $ S.enumerateFromTo 1.1 4.6
379+ --
380+ -- >>> Stream.toList $ Stream.enumerateFromTo 1.1 4.6
361381 -- [1.1,2.1,3.1,4.1,5.1]
382+ --
362383 -- @
363384 --
364385 -- @since 0.6.0
@@ -372,10 +393,12 @@ class Enum a => Enumerable a where
372393 -- unbounded types it keeps enumerating infinitely.
373394 --
374395 -- @
375− -- > S.toList $ S.take 4 $ S.enumerateFromThen 0 2
396+ -- >>> Stream.toList $ Stream.take 4 $ Stream.enumerateFromThen 0 2
376397 -- [0,2,4,6]
377− -- > S.toList $ S.take 4 $ S.enumerateFromThen 0 (-2)
398+ --
399+ -- >>> Stream.toList $ Stream.take 4 $ Stream.enumerateFromThen 0 (-2)
378400 -- [0,-2,-4,-6]
401+ --
379402 -- @
380403 --
381404 -- @since 0.6.0
@@ -388,10 +411,12 @@ class Enum a => Enumerable a where
388411 -- after @from@.
389412 --
390413 -- @
391− -- > S.toList $ S.enumerateFromThenTo 0 2 6
414+ -- >>> Stream.toList $ Stream.enumerateFromThenTo 0 2 6
392415 -- [0,2,4,6]
393− -- > S.toList $ S.enumerateFromThenTo 0 (-2) (-6)
416+ --
417+ -- >>> Stream.toList $ Stream.enumerateFromThenTo 0 (-2) (-6)
394418 -- [0,-2,-4,-6]
419+ --
395420 -- @
396421 --
397422 -- @since 0.6.0
src/Streamly/Internal/Data/Stream/IsStream/Expand.hs+15−13
@@ -187,6 +187,7 @@ import Prelude hiding (concat, concatMap)
187187
188188-- $setup
189189-- >>> :m
190+-- >>> import Data.IORef
190191-- >>> import Prelude hiding (zipWith, concatMap, concat)
191192-- >>> import qualified Streamly.Prelude as Stream
192193-- >>> import Streamly.Internal.Data.Stream.IsStream as Stream
@@ -237,6 +238,7 @@ append m1 m2 = fromStreamD $ D.append (toStreamD m1) (toStreamD m2)
237238-- >>> import Data.Functor.Identity (Identity)
238239-- >>> Stream.interleave "ab" ",,,," :: Stream.SerialT Identity Char
239240-- fromList "a,b,,,"
241+--
240242-- >>> Stream.interleave "abcd" ",," :: Stream.SerialT Identity Char
241243-- fromList "a,b,cd"
242244--
@@ -369,27 +371,27 @@ mergeBy f m1 m2 = fromStreamS $ S.mergeBy f (toStreamS m1) (toStreamS m2)
369371--
370372-- @
371373-- > randomly _ _ = randomIO >>= \x -> return $ if x then LT else GT
372−-- > S.toList $ S.mergeByM randomly (S.fromList [1,1,1,1]) (S.fromList [2,2,2,2])
374+-- > Stream.toList $ Stream.mergeByM randomly (Stream.fromList [1,1,1,1]) (Stream.fromList [2,2,2,2])
373375-- [2,1,2,2,2,1,1,1]
374376-- @
375377--
376378-- Merge two streams in a proportion of 2:1:
377379--
378380-- @
379−-- proportionately m n = do
380−-- ref <- newIORef $ cycle $ concat [replicate m LT, replicate n GT]
381−-- return $ \\_ _ -> do
382−-- r <- readIORef ref
383−-- writeIORef ref $ tail r
384−-- return $ head r
385−--
386−-- main = do
381+-- >>> :{
382+-- do
383+-- let proportionately m n = do
384+-- ref <- newIORef $ cycle $ Prelude.concat [Prelude.replicate m LT, Prelude.replicate n GT]
385+-- return $ \_ _ -> do
386+-- r <- readIORef ref
387+-- writeIORef ref $ Prelude.tail r
388+-- return $ Prelude.head r
387389-- f <- proportionately 2 1
388−-- xs <- S.toList $ S.mergeByM f (S.fromList [1,1,1,1,1,1]) (S.fromList [2,2,2])
390+-- xs <- Stream.toList $ Stream.mergeByM f (Stream.fromList [1,1,1,1,1,1]) (Stream.fromList [2,2,2])
389391-- print xs
390−-- @
391−-- @
392+-- :}
392393-- [1,1,2,1,1,2,1,1,2]
394+--
393395-- @
394396--
395397-- @since 0.6.0
@@ -420,7 +422,7 @@ mergeEndByFirst f m1 m2 = fromStreamS $
420422-- | Same as @'mergeBy' 'compare'@.
421423--
422424-- @
423−-- > S.toList $ S.merge (S.fromList [1,3,5]) (S.fromList [2,4,6,8])
425+-- >>> Stream.toList $ Stream.merge (Stream.fromList [1,3,5]) (Stream.fromList [2,4,6,8])
424426-- [1,2,3,4,5,6,8]
425427-- @
426428--
src/Streamly/Internal/Data/Stream/IsStream/Generate.hs+12−12
@@ -168,14 +168,15 @@ unfold0 unf = unfold unf (error "unfold0: unexpected void evaluation")
168168-- For example,
169169--
170170-- @
171+-- >>> :{
171172-- let f b =
172173-- if b > 3
173174-- then Nothing
174175-- else Just (b, b + 1)
175−-- in toList $ unfoldr f 0
176−-- @
177−-- @
176+-- in Stream.toList $ Stream.unfoldr f 0
177+-- :}
178178-- [0,1,2,3]
179+--
179180-- @
180181--
181182-- @since 0.1.0
@@ -191,17 +192,15 @@ unfoldr step seed = fromStreamS (S.unfoldr step seed)
191192-- example,
192193--
193194-- @
195+-- >>> :{
194196-- let f b =
195197-- if b > 3
196198-- then return Nothing
197−-- else print b >> return (Just (b, b + 1))
198−-- in drain $ unfoldrM f 0
199−-- @
200−-- @
201−-- 0
202−-- 1
203−-- 2
204−-- 3
199+-- else return (Just (b, b + 1))
200+-- in Stream.toList $ Stream.unfoldrM f 0
201+-- :}
202+-- [0,1,2,3]
203+--
205204-- @
206205-- When run concurrently, the next unfold step can run concurrently with the
207206-- processing of the output of the previous step. Note that more than one step
@@ -444,8 +443,9 @@ fromIndicesMSerial = fromStreamS . S.fromIndicesM
444443-- element.
445444--
446445-- @
447−-- > S.toList $ S.take 5 $ S.iterate (+1) 1
446+-- >>> Stream.toList $ Stream.take 5 $ Stream.iterate (+1) 1
448447-- [1,2,3,4,5]
448+--
449449-- @
450450--
451451-- @since 0.1.2
src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+4−4
@@ -312,10 +312,10 @@ foldSequence _f _m = undefined
312312-- the fold is used to generate the next fold and so on.
313313--
314314-- @
315−-- > import Data.Monoid (Sum(..))
316−-- > f x = return (Fold.take 2 (Fold.sconcat x))
317−-- > s = Stream.map Sum $ Stream.fromList [1..10]
318−-- > Stream.toList $ Stream.map getSum $ Stream.foldIterateM f 0 s
315+-- >>> import Data.Monoid (Sum(..))
316+-- >>> f x = return (Fold.take 2 (Fold.sconcat x))
317+-- >>> s = Stream.map Sum $ Stream.fromList [1..10]
318+-- >>> Stream.toList $ Stream.map getSum $ Stream.foldIterateM f 0 s
319319-- [3,10,21,36,55,55]
320320--
321321-- @
src/Streamly/Internal/Data/Stream/IsStream/Transform.hs+75−41
@@ -263,6 +263,9 @@ import Prelude hiding
263263--
264264-- $setup
265265-- >>> :m
266+-- >>> import Control.Concurrent (threadDelay)
267+-- >>> import Data.Function ((&))
268+-- >>> import Streamly.Prelude ((|$))
266269-- >>> import Prelude hiding ( filter, drop, dropWhile, take, takeWhile, foldr, map, mapM, sequence, reverse, foldr1 , scanl, scanl1)
267270-- >>> import qualified Streamly.Prelude as Stream
268271-- >>> import Streamly.Internal.Data.Stream.IsStream as Stream
@@ -287,7 +290,7 @@ transform pipe xs = fromStreamD $ D.transform pipe (toStreamD xs)
287290
288291-- | Right fold to a streaming monad.
289292--
290−-- > foldrS S.cons S.nil === id
293+-- > foldrS Stream.cons Stream.nil === id
291294--
292295-- 'foldrS' can be used to perform stateless stream to stream transformations
293296-- like map and filter in general. It can be coupled with a scan to perform
@@ -346,14 +349,19 @@ foldrT f z s = S.foldrT f z (toStreamS s)
346349-- the output of the resulting action.
347350--
348351-- @
349−-- > drain $ S.mapM putStr $ S.fromList ["a", "b", "c"]
352+-- >>> drain $ Stream.mapM putStr $ Stream.fromList ["a", "b", "c"]
350353-- abc
351354--
352−-- drain $ S.replicateM 10 (return 1)
353−-- & (fromSerial . S.mapM (\\x -> threadDelay 1000000 >> print x))
355+-- >>> :{
356+-- drain $ Stream.replicateM 10 (return 1)
357+-- & (fromSerial . Stream.mapM (\x -> threadDelay 1000000 >> print x))
358+-- :}
359+-- 1
360+-- ...
361+-- 1
354362--
355−-- drain $ S.replicateM 10 (return 1)
356−-- & (fromAsync . S.mapM (\\x -> threadDelay 1000000 >> print x))
363+-- > drain $ Stream.replicateM 10 (return 1)
364+-- & (fromAsync . Stream.mapM (\x -> threadDelay 1000000 >> print x))
357365-- @
358366--
359367-- /Concurrent (do not use with 'fromParallel' on infinite streams)/
@@ -377,14 +385,25 @@ mapMSerial = Serial.mapM
377385-- those actions.
378386--
379387-- @
380−-- > drain $ S.sequence $ S.fromList [putStr "a", putStr "b", putStrLn "c"]
388+-- >>> drain $ Stream.sequence $ Stream.fromList [putStr "a", putStr "b", putStrLn "c"]
381389-- abc
382390--
383−-- drain $ S.replicateM 10 (return $ threadDelay 1000000 >> print 1)
384−-- & (fromSerial . S.sequence)
391+-- >>> :{
392+-- drain $ Stream.replicateM 10 (return $ threadDelay 1000000 >> print 1)
393+-- & (fromSerial . Stream.sequence)
394+-- :}
395+-- 1
396+-- ...
397+-- 1
398+--
399+-- >>> :{
400+-- drain $ Stream.replicateM 10 (return $ threadDelay 1000000 >> print 1)
401+-- & (fromAsync . Stream.sequence)
402+-- :}
403+-- 1
404+-- ...
405+-- 1
385406--
386−-- drain $ S.replicateM 10 (return $ threadDelay 1000000 >> print 1)
387−-- & (fromAsync . S.sequence)
388407-- @
389408--
390409-- /Concurrent (do not use with 'fromParallel' on infinite streams)/
@@ -451,9 +470,10 @@ tapOffsetEvery offset n f xs =
451470-- @
452471--
453472-- @
454−-- > S.drain $ S.tapAsync (S.mapM_ print) (S.enumerateFromTo 1 2)
473+-- >>> Stream.drain $ Stream.tapAsync (Fold.drainBy print) (Stream.enumerateFromTo 1 2)
455474-- 1
456475-- 2
476+--
457477-- @
458478--
459479-- Exceptions from the concurrently running fold are propagated to the current
@@ -479,8 +499,8 @@ tapAsync f xs = D.fromStreamD $ Par.tapAsyncF f (D.toStreamD xs)
479499-- For example, to print the count of elements processed every second:
480500--
481501-- @
482−-- > S.drain $ S.pollCounts (const True) (S.rollingMap (-) . S.delayPost 1) (FL.drainBy print)
483−-- $ S.enumerateFrom 0
502+-- > Stream.drain $ Stream.pollCounts (const True) (Stream.rollingMap (-) . Stream.delayPost 1) (FLold.drainBy print)
503+-- $ Stream.enumerateFrom 0
484504-- @
485505--
486506-- Note: This may not work correctly on 32-bit machines.
@@ -509,9 +529,10 @@ pollCounts predicate transf f xs =
509529--
510530-- @
511531-- > delay n = threadDelay (round $ n * 1000000) >> return n
512−-- > S.drain $ S.tapRate 2 (\\n -> print $ show n ++ " elements processed") (delay 1 S.|: delay 0.5 S.|: delay 0.5 S.|: S.nil)
513−-- 2 elements processed
514−-- 1 elements processed
532+-- > Stream.toList $ Stream.tapRate 2 (\n -> print $ show n ++ " elements processed") (delay 1 Stream.|: delay 0.5 Stream.|: delay 0.5 Stream.|: Stream.nil)
533+-- "2 elements processed"
534+-- [1.0,0.5,0.5]
535+-- "1 elements processed"
515536-- @
516537--
517538-- Note: This may not work correctly on 32-bit machines.
@@ -530,9 +551,10 @@ tapRate n f xs = D.fromStreamD $ D.tapRate n f $ D.toStreamD xs
530551-- discard the results.
531552--
532553-- @
533−-- > S.drain $ S.trace print (S.enumerateFromTo 1 2)
554+-- >>> Stream.drain $ Stream.trace print (Stream.enumerateFromTo 1 2)
534555-- 1
535556-- 2
557+--
536558-- @
537559--
538560-- Compare with 'tap'.
@@ -546,9 +568,10 @@ trace f = mapM (\x -> void (f x) >> return x)
546568-- discard the results.
547569--
548570-- @
549−-- > S.drain $ S.trace_ (print "got here") (S.enumerateFromTo 1 2)
571+-- >>> Stream.drain $ Stream.trace_ (print "got here") (Stream.enumerateFromTo 1 2)
550572-- "got here"
551573-- "got here"
574+--
552575-- @
553576--
554577-- Same as 'interspersePrefix_' but always serial.
@@ -643,13 +666,15 @@ scanlM' step begin m = fromStreamD $ D.scanlM' step begin $ toStreamD m
643666-- however it adds an extra element.
644667--
645668-- @
646−-- > S.toList $ S.scanl' (+) 0 $ fromList [1,2,3,4]
669+-- >>> Stream.toList $ Stream.scanl' (+) 0 $ fromList [1,2,3,4]
647670-- [0,1,3,6,10]
671+--
648672-- @
649673--
650674-- @
651−-- > S.toList $ S.scanl' (flip (:)) [] $ S.fromList [1,2,3,4]
675+-- >>> Stream.toList $ Stream.scanl' (flip (:)) [] $ Stream.fromList [1,2,3,4]
652676-- [[],[1],[2,1],[3,2,1],[4,3,2,1]]
677+--
653678-- @
654679--
655680-- The output of 'scanl'' is the initial value of the accumulator followed by
@@ -665,18 +690,22 @@ scanlM' step begin m = fromStreamD $ D.scanlM' step begin $ toStreamD m
665690-- of the elements in a stream in one go using a @foldl'@:
666691--
667692-- @
668−-- > S.foldl' (\\(s, p) x -> (s + x, p * x)) (0,1) $ S.fromList \[1,2,3,4]
693+-- >>> Stream.foldl' (\(s, p) x -> (s + x, p * x)) (0,1) $ Stream.fromList [1,2,3,4]
669694-- (10,24)
695+--
670696-- @
671697--
672698-- Using @scanl'@ we can make it modular by computing the sum in the first
673699-- stage and passing it down to the next stage for computing the product:
674700--
675701-- @
676−-- > S.foldl' (\\(_, p) (s, x) -> (s, p * x)) (0,1)
677−-- $ S.scanl' (\\(s, _) x -> (s + x, x)) (0,1)
678−-- $ S.fromList \[1,2,3,4]
702+-- >>> :{
703+-- Stream.foldl' (\(_, p) (s, x) -> (s, p * x)) (0,1)
704+-- $ Stream.scanl' (\(s, _) x -> (s + x, x)) (0,1)
705+-- $ Stream.fromList [1,2,3,4]
706+-- :}
679707-- (10,24)
708+--
680709-- @
681710--
682711-- IMPORTANT: 'scanl'' evaluates the accumulator to WHNF. To avoid building
@@ -692,7 +721,7 @@ scanl' step z m = fromStreamS $ S.scanl' step z $ toStreamS m
692721
693722-- | Like 'scanl'' but does not stream the initial value of the accumulator.
694723--
695−-- > postscanl' f z xs = S.drop 1 $ S.scanl' f z xs
724+-- > postscanl' f z xs = Stream.drop 1 $ Stream.scanl' f z xs
696725--
697726-- @since 0.7.0
698727{-# INLINE postscanl' #-}
@@ -730,8 +759,9 @@ scanl1M' step m = fromStreamD $ D.scanl1M' step $ toStreamD m
730759-- is empty.
731760--
732761-- @
733−-- > S.toList $ S.scanl1 (+) $ fromList [1,2,3,4]
762+-- >>> Stream.toList $ Stream.scanl1' (+) $ fromList [1,2,3,4]
734763-- [1,3,6,10]
764+--
735765-- @
736766--
737767-- @since 0.6.0
@@ -821,8 +851,9 @@ uniq = fromStreamD . D.uniq . toStreamD
821851-- @
822852--
823853-- @
824−-- > Stream.pruneBy isSpace (Stream.fromList " hello world! ")
854+-- > Stream.prune isSpace (Stream.fromList " hello world! ")
825855-- "hello world!"
856+--
826857-- @
827858--
828859-- Space: @O(1)@
@@ -880,8 +911,9 @@ nubWindowBy = undefined -- fromStreamD . D.nubWithinBy . toStreamD
880911-- the given equality predicate.
881912--
882913-- @
883−-- > S.toList $ S.deleteBy (==) 3 $ S.fromList [1,3,3,5]
914+-- >>> Stream.toList $ Stream.deleteBy (==) 3 $ Stream.fromList [1,3,3,5]
884915-- [1,3,5]
916+--
885917-- @
886918--
887919-- @since 0.6.0
@@ -1096,8 +1128,9 @@ dropWhileAround = undefined -- fromStreamD $ D.dropWhileAround n $ toStreamD m
10961128-- @
10971129--
10981130-- @
1099−-- > S.toList $ S.insertBy compare 2 $ S.fromList [1,3,5]
1131+-- >>> Stream.toList $ Stream.insertBy compare 2 $ Stream.fromList [1,3,5]
11001132-- [1,2,3,5]
1133+--
11011134-- @
11021135--
11031136-- @since 0.6.0
@@ -1131,8 +1164,9 @@ intersperseM_ m = fromStreamD . D.intersperseM_ m . toStreamD
11311164-- elements.
11321165--
11331166-- @
1134−-- > S.toList $ S.intersperseBySpan 2 (return ',') $ S.fromList "hello"
1167+-- > Stream.toList $ Stream.intersperseBySpan 2 (return ',') $ Stream.fromList "hello"
11351168-- "he,ll,o"
1169+--
11361170-- @
11371171--
11381172-- /Unimplemented/
@@ -1154,7 +1188,9 @@ intersperseSuffix m = fromStreamD . D.intersperseSuffix m . toStreamD
11541188-- | Insert a side effect after consuming an element of a stream.
11551189--
11561190-- @
1157−-- > S.mapM_ putChar $ S.intersperseSuffix_ (threadDelay 1000000) $ S.fromList "hello"
1191+-- >>> Stream.mapM_ putChar $ Stream.intersperseSuffix_ (threadDelay 1000000) $ Stream.fromList "hello"
1192+-- hello
1193+--
11581194-- @
11591195--
11601196-- /Pre-release/
@@ -1270,8 +1306,8 @@ reassembleBy = undefined
12701306------------------------------------------------------------------------------
12711307
12721308-- |
1273−-- > indexed = S.postscanl' (\(i, _) x -> (i + 1, x)) (-1,undefined)
1274−-- > indexed = S.zipWith (,) (S.enumerateFrom 0)
1309+-- > indexed = Stream.postscanl' (\(i, _) x -> (i + 1, x)) (-1,undefined)
1310+-- > indexed = Stream.zipWith (,) (Stream.enumerateFrom 0)
12751311--
12761312-- Pair each element in a stream with its index, starting from index 0.
12771313--
@@ -1284,8 +1320,8 @@ indexed :: (IsStream t, Monad m) => t m a -> t m (Int, a)
12841320indexed = fromStreamD . D.indexed . toStreamD
12851321
12861322-- |
1287−-- > indexedR n = S.postscanl' (\(i, _) x -> (i - 1, x)) (n + 1,undefined)
1288−-- > indexedR n = S.zipWith (,) (S.enumerateFromThen n (n - 1))
1323+-- > indexedR n = Stream.postscanl' (\(i, _) x -> (i - 1, x)) (n + 1,undefined)
1324+-- > indexedR n = Stream.zipWith (,) (Stream.enumerateFromThen n (n - 1))
12891325--
12901326-- Pair each element in a stream with its index, starting from the
12911327-- given index @n@ and counting down.
@@ -1307,7 +1343,7 @@ indexedR n = fromStreamD . D.indexedR n . toStreamD
13071343-- If we do not do that then the following example will generate the same
13081344-- timestamp for first two elements:
13091345--
1310−-- S.mapM_ print $ S.timestamped $ S.delay $ S.enumerateFromTo 1 3
1346+-- Stream.mapM_ print $ Stream.timestamped $ Stream.delay $ Stream.enumerateFromTo 1 3
13111347--
13121348-- | Pair each element in a stream with an absolute timestamp, using a clock of
13131349-- specified granularity. The timestamp is generated just before the element
@@ -1416,7 +1452,7 @@ rollingMapM f m = fromStreamD $ D.rollingMapM f $ toStreamD m
14161452-- Equivalent to:
14171453--
14181454-- @
1419−-- mapMaybe f = S.map 'fromJust' . S.filter 'isJust' . S.map f
1455+-- mapMaybe f = Stream.map 'fromJust' . Stream.filter 'isJust' . Stream.map f
14201456-- @
14211457--
14221458-- @since 0.3.0
@@ -1429,7 +1465,7 @@ mapMaybe f m = fromStreamS $ S.mapMaybe f $ toStreamS m
14291465-- Equivalent to:
14301466--
14311467-- @
1432−-- mapMaybeM f = S.map 'fromJust' . S.filter 'isJust' . S.mapM f
1468+-- mapMaybeM f = Stream.map 'fromJust' . Stream.filter 'isJust' . Stream.mapM f
14331469-- @
14341470--
14351471-- /Concurrent (do not use with 'fromParallel' on infinite streams)/
@@ -1489,8 +1525,6 @@ rights = fmap (fromRight undefined) . filter isRight
14891525-- 1 second delay.
14901526--
14911527--
1492−-- >>> import Control.Concurrent (threadDelay)
1493−-- >>> import Streamly.Prelude ((|$))
14941528-- >>> :{
14951529-- Stream.drain $
14961530-- Stream.mapM (\x -> threadDelay 1000000 >> print x)
src/Streamly/Prelude.hs+8−6
@@ -1126,8 +1126,9 @@ import Streamly.Internal.Data.Stream.IsStream
11261126-- works. For example:
11271127--
11281128-- @
1129−-- > S.foldl' (+) 0 $ S.fromList [1,2,3,4]
1129+-- >>> Stream.foldl' (+) 0 $ Stream.fromList [1,2,3,4]
11301130-- 10
1131+--
11311132-- @
11321133--
11331134-- @
@@ -1150,8 +1151,9 @@ import Streamly.Internal.Data.Stream.IsStream
11501151-- reverse (LIFO) order:
11511152--
11521153-- @
1153−-- > S.foldl' (flip (:)) [] $ S.fromList [1,2,3,4]
1154+-- >>> Stream.foldl' (flip (:)) [] $ Stream.fromList [1,2,3,4]
11541155-- [4,3,2,1]
1156+--
11551157-- @
11561158--
11571159-- A left fold is a push fold. The producer pushes its contents to the step
@@ -1200,8 +1202,8 @@ import Streamly.Internal.Data.Stream.IsStream
12001202--
12011203-- @
12021204-- ...
1203−-- $ S.maxBuffer 10
1204−-- $ S.mapM ...
1205+-- $ Stream.maxBuffer 10
1206+-- $ Stream.mapM ...
12051207-- ...
12061208-- @
12071209--
@@ -1211,8 +1213,8 @@ import Streamly.Internal.Data.Stream.IsStream
12111213--
12121214-- @
12131215-- ...
1214−-- & S.maxBuffer 10
1215−-- & S.mapM ...
1216+-- & Stream.maxBuffer 10
1217+-- & Stream.mapM ...
12161218-- ...
12171219-- @
12181220