on master help sign in
Make streamly-core free from IsStream (#1796)
7278ecbRanjeet Ranjan
core/src/Streamly/Data/Fold.hs+6−6
@@ -12,7 +12,7 @@
12--
12--
13-- >>> import Data.Function ((&))
13-- >>> import Data.Function ((&))
14-- >>> import qualified Streamly.Data.Fold as Fold
14-- >>> import qualified Streamly.Data.Fold as Fold
15−-- >>> import qualified Streamly.Prelude as Stream
15+-- >>> import qualified Streamly.Data.Stream as Stream
16--
16--
17-- For example, a 'sum' Fold represents adding the input to the accumulated
17-- For example, a 'sum' Fold represents adding the input to the accumulated
18-- sum. A fold driver e.g. 'Streamly.Prelude.fold' pushes values from a stream
18-- sum. A fold driver e.g. 'Streamly.Prelude.fold' pushes values from a stream
@@ -59,7 +59,7 @@
59-- folds. For example, to count even and odd numbers in a stream:
59-- folds. For example, to count even and odd numbers in a stream:
60--
60--
61-- >>> split n = if even n then Left n else Right n
61-- >>> split n = if even n then Left n else Right n
62−-- >>> stream = Stream.map split $ Stream.fromList [1..100]
62+-- >>> stream = fmap split $ Stream.fromList [1..100]
63-- >>> countEven = fmap (("Even " ++) . show) Fold.length
63-- >>> countEven = fmap (("Even " ++) . show) Fold.length
64-- >>> countOdd = fmap (("Odd " ++) . show) Fold.length
64-- >>> countOdd = fmap (("Odd " ++) . show) Fold.length
65-- >>> f = Fold.partition countEven countOdd
65-- >>> f = Fold.partition countEven countOdd
@@ -78,7 +78,7 @@
78-- of fold results. To split a stream on newlines:
78-- of fold results. To split a stream on newlines:
79--
79--
80-- >>> f = Fold.takeEndBy (== '\n') Fold.toList
80-- >>> f = Fold.takeEndBy (== '\n') Fold.toList
81−-- >>> Stream.toList $ Stream.foldMany f $ Stream.fromList "Hello there!\nHow are you\n"
81+-- >>> Stream.fold Fold.toList $ Stream.foldMany f $ Stream.fromList "Hello there!\nHow are you\n"
82-- ["Hello there!\n","How are you\n"]
82-- ["Hello there!\n","How are you\n"]
83--
83--
84-- Similarly, we can split the input of a fold too:
84-- Similarly, we can split the input of a fold too:
@@ -102,8 +102,8 @@
102-- >>> :{
102-- >>> :{
103-- f stream =
103-- f stream =
104-- Stream.filter odd stream
104-- Stream.filter odd stream
105−-- & Stream.map (+1)
105+-- & fmap (+1)
106−-- & Stream.sum
106+-- & Stream.fold Fold.sum
107-- :}
107-- :}
108--
108--
109-- >>> f $ Stream.fromList [1..100 :: Int]
109-- >>> f $ Stream.fromList [1..100 :: Int]
@@ -286,4 +286,4 @@ import Streamly.Internal.Data.Fold
286-- $setup
286-- $setup
287-- >>> import Data.Function ((&))
287-- >>> import Data.Function ((&))
288-- >>> import qualified Streamly.Data.Fold as Fold
288-- >>> import qualified Streamly.Data.Fold as Fold
289−-- >>> import qualified Streamly.Prelude as Stream
289+-- >>> import qualified Streamly.Data.Stream as Stream
core/src/Streamly/Data/Fold/Tee.hs+1−1
@@ -15,7 +15,7 @@
15-- through the stream twice:
15-- through the stream twice:
16--
16--
17-- >>> import Streamly.Data.Fold.Tee (Tee(..))
17-- >>> import Streamly.Data.Fold.Tee (Tee(..))
18−-- >>> import qualified Streamly.Prelude as Stream
18+-- >>> import qualified Streamly.Data.Stream as Stream
19-- >>> import qualified Streamly.Data.Fold as Fold
19-- >>> import qualified Streamly.Data.Fold as Fold
20--
20--
21-- >>> avg = (/) <$> (Tee Fold.sum) <*> (Tee $ fmap fromIntegral Fold.length)
21-- >>> avg = (/) <$> (Tee Fold.sum) <*> (Tee $ fmap fromIntegral Fold.length)
core/src/Streamly/Internal/Data/Array/Mut/Type.hs+1−1
@@ -181,7 +181,7 @@ import Prelude hiding (read)
181-- >>> :m
181-- >>> :m
182-- >>> :set -package streamly
182-- >>> :set -package streamly
183-- >>> import qualified Streamly.Internal.Data.Array.Mut.Type as Array
183-- >>> import qualified Streamly.Internal.Data.Array.Mut.Type as Array
184−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream
184+-- >>> import qualified Streamly.Internal.Data.Stream as Stream
185-- >>> import qualified Streamly.Internal.Data.Stream.StreamD as StreamD
185-- >>> import qualified Streamly.Internal.Data.Stream.StreamD as StreamD
186-- >>> import qualified Streamly.Internal.Data.Fold as Fold
186-- >>> import qualified Streamly.Internal.Data.Fold as Fold
187-- >>> import qualified Streamly.Internal.Data.Fold.Type as Fold
187-- >>> import qualified Streamly.Internal.Data.Fold.Type as Fold
core/src/Streamly/Internal/Data/Array/Stream/Fold/Foreign.hs+2−2
@@ -20,8 +20,8 @@
20-- >>> import qualified Streamly.Data.Fold as Fold
20-- >>> import qualified Streamly.Data.Fold as Fold
21-- >>> import qualified Streamly.Internal.Data.Array.Stream.Foreign as ArrayStream
21-- >>> import qualified Streamly.Internal.Data.Array.Stream.Foreign as ArrayStream
22-- >>> import qualified Streamly.Internal.Data.Array.Stream.Fold.Foreign as ArrayFold
22-- >>> import qualified Streamly.Internal.Data.Array.Stream.Fold.Foreign as ArrayFold
23−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream (arraysOf)
23+-- >>> import qualified Streamly.Internal.Data.Stream as Stream (arraysOf)
24−-- >>> import qualified Streamly.Prelude as Stream
24+-- >>> import qualified Streamly.Data.Stream as Stream
25--
25--
26-- >>> f = ArrayFold.fromFold (Fold.take 7 Fold.toList)
26-- >>> f = ArrayFold.fromFold (Fold.take 7 Fold.toList)
27-- >>> s = Stream.arraysOf 5 $ Stream.fromList "hello world"
27-- >>> s = Stream.arraysOf 5 $ Stream.fromList "hello world"
core/src/Streamly/Internal/Data/Array/Unboxed/Mut/Type.hs+1−1
@@ -270,7 +270,7 @@ import Prelude hiding
270-- $setup
270-- $setup
271-- >>> :m
271-- >>> :m
272-- >>> import qualified Streamly.Internal.Data.Array.Unboxed.Mut.Type as Array
272-- >>> import qualified Streamly.Internal.Data.Array.Unboxed.Mut.Type as Array
273−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream
273+-- >>> import qualified Streamly.Internal.Data.Stream as Stream
274-- >>> import qualified Streamly.Internal.Data.Stream.StreamD as StreamD
274-- >>> import qualified Streamly.Internal.Data.Stream.StreamD as StreamD
275-- >>> import qualified Streamly.Internal.Data.Fold as Fold
275-- >>> import qualified Streamly.Internal.Data.Fold as Fold
276-- >>> import qualified Streamly.Internal.Data.Fold.Type as Fold
276-- >>> import qualified Streamly.Internal.Data.Fold.Type as Fold
core/src/Streamly/Internal/Data/Fold.hs+7−8
@@ -339,8 +339,7 @@ import Streamly.Internal.Data.Fold.Type
339-- >>> :m
339-- >>> :m
340-- >>> :set -package streamly
340-- >>> :set -package streamly
341-- >>> import Prelude hiding (break, map, span, splitAt)
341-- >>> import Prelude hiding (break, map, span, splitAt)
342−-- >>> import qualified Streamly.Prelude as Stream
342+-- >>> import qualified Streamly.Data.Stream as Stream
343−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream (catMaybes, parse, foldMany)
344-- >>> import qualified Streamly.Data.Fold as Fold
343-- >>> import qualified Streamly.Data.Fold as Fold
345-- >>> import qualified Streamly.Internal.Data.Fold as Fold
344-- >>> import qualified Streamly.Internal.Data.Fold as Fold
346-- >>> import qualified Streamly.Internal.Data.Fold.Type as Fold
345-- >>> import qualified Streamly.Internal.Data.Fold.Type as Fold
@@ -598,7 +597,7 @@ foldFilter f1 f2 = many f1 (catMaybes f2)
598-- returns 'Nothing' for any other occurrences.
597-- returns 'Nothing' for any other occurrences.
599--
598--
600-- >>> stream = Stream.fromList [1::Int,1,2,3,4,4,5,1,5,7]
599-- >>> stream = Stream.fromList [1::Int,1,2,3,4,4,5,1,5,7]
601−-- >>> Stream.toList $ Stream.catMaybes $ Stream.postscan Fold.nub stream
600+-- >>> Stream.fold Fold.toList $ Stream.mapMaybe id $ Stream.postscan Fold.nub stream
602-- [1,2,3,4,5,7]
601-- [1,2,3,4,5,7]
603--
602--
604-- /Pre-release/
603-- /Pre-release/
@@ -990,7 +989,7 @@ rollingMapM f = Fold step initial extract
990
989
991-- | Append the elements of an input stream to a provided starting value.
990-- | Append the elements of an input stream to a provided starting value.
992--
991--
993−-- >>> Stream.fold (Fold.sconcat 10) (Stream.map Data.Monoid.Sum $ Stream.enumerateFromTo 1 10)
992+-- >>> Stream.fold (Fold.sconcat 10) (fmap Data.Monoid.Sum $ Stream.enumerateFromTo 1 10)
994-- Sum {getSum = 65}
993-- Sum {getSum = 65}
995--
994--
996-- @
995-- @
@@ -1005,7 +1004,7 @@ sconcat = foldl' (<>)
1005-- | Fold an input stream consisting of monoidal elements using 'mappend'
1004-- | Fold an input stream consisting of monoidal elements using 'mappend'
1006-- and 'mempty'.
1005-- and 'mempty'.
1007--
1006--
1008−-- >>> Stream.fold Fold.mconcat (Stream.map Data.Monoid.Sum $ Stream.enumerateFromTo 1 10)
1007+-- >>> Stream.fold Fold.mconcat (fmap Data.Monoid.Sum $ Stream.enumerateFromTo 1 10)
1009-- Sum {getSum = 55}
1008-- Sum {getSum = 55}
1010--
1009--
1011-- > mconcat = Fold.sconcat mempty
1010-- > mconcat = Fold.sconcat mempty
@@ -1404,7 +1403,7 @@ splitAt n fld = serialWith (,) (take n fld)
1404-- >>> Stream.fold (Fold.takeEndBy_ (== '\n') Fold.toList) $ Stream.fromList "hello\nthere\n"
1403-- >>> Stream.fold (Fold.takeEndBy_ (== '\n') Fold.toList) $ Stream.fromList "hello\nthere\n"
1405-- "hello"
1404-- "hello"
1406--
1405--
1407−-- >>> Stream.toList $ Stream.foldMany (Fold.takeEndBy_ (== '\n') Fold.toList) $ Stream.fromList "hello\nthere\n"
1406+-- >>> Stream.fold Fold.toList $ Stream.foldMany (Fold.takeEndBy_ (== '\n') Fold.toList) $ Stream.fromList "hello\nthere\n"
1408-- ["hello","there"]
1407-- ["hello","there"]
1409--
1408--
1410-- > Stream.splitOnSuffix p f = Stream.foldMany (Fold.takeEndBy_ p f)
1409-- > Stream.splitOnSuffix p f = Stream.foldMany (Fold.takeEndBy_ p f)
@@ -1431,7 +1430,7 @@ takeEndBy_ predicate (Fold fstep finitial fextract) =
1431-- >>> Stream.fold (Fold.takeEndBy (== '\n') Fold.toList) $ Stream.fromList "hello\nthere\n"
1430-- >>> Stream.fold (Fold.takeEndBy (== '\n') Fold.toList) $ Stream.fromList "hello\nthere\n"
1432-- "hello\n"
1431-- "hello\n"
1433--
1432--
1434−-- >>> Stream.toList $ Stream.foldMany (Fold.takeEndBy (== '\n') Fold.toList) $ Stream.fromList "hello\nthere\n"
1433+-- >>> Stream.fold Fold.toList $ Stream.foldMany (Fold.takeEndBy (== '\n') Fold.toList) $ Stream.fromList "hello\nthere\n"
1435-- ["hello\n","there\n"]
1434-- ["hello\n","there\n"]
1436--
1435--
1437-- > Stream.splitWithSuffix p f = Stream.foldMany (Fold.takeEndBy p f)
1436-- > Stream.splitWithSuffix p f = Stream.foldMany (Fold.takeEndBy p f)
@@ -1479,7 +1478,7 @@ data SplitOnSeqState acc a rb rh w ck =
1479-- >>> Stream.fold f s
1478-- >>> Stream.fold f s
1480-- "hello there"
1479-- "hello there"
1481--
1480--
1482−-- >>> Stream.toList $ Stream.foldMany f s
1481+-- >>> Stream.fold Fold.toList $ Stream.foldMany f s
1483-- ["hello there",". How are"," you?"]
1482-- ["hello there",". How are"," you?"]
1484--
1483--
1485-- /Pre-release/
1484-- /Pre-release/
core/src/Streamly/Internal/Data/Fold/Type.hs+2−4
@@ -416,12 +416,10 @@ import Prelude hiding (concatMap, filter, foldr, map, take)
416-- >>> import Streamly.Data.Fold (Fold)
416-- >>> import Streamly.Data.Fold (Fold)
417-- >>> import Streamly.Internal.Data.Stream.Type (Stream)
417-- >>> import Streamly.Internal.Data.Stream.Type (Stream)
418-- >>> import qualified Data.Foldable as Foldable
418-- >>> import qualified Data.Foldable as Foldable
419−-- >>> import qualified Streamly.Prelude as Stream
420-- >>> import qualified Streamly.Data.Fold as Fold
419-- >>> import qualified Streamly.Data.Fold as Fold
421-- >>> import qualified Streamly.Internal.Data.Fold as Fold
420-- >>> import qualified Streamly.Internal.Data.Fold as Fold
422-- >>> import qualified Streamly.Internal.Data.Fold.Type as Fold
421-- >>> import qualified Streamly.Internal.Data.Fold.Type as Fold
423−-- >>> import qualified Streamly.Internal.Data.Stream.Type as Stream
422+-- >>> import qualified Streamly.Internal.Data.Stream as Stream
424−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream
425-- >>> import qualified Streamly.Internal.Data.Stream.StreamK as StreamK
423-- >>> import qualified Streamly.Internal.Data.Stream.StreamK as StreamK
426-- >>> import Prelude hiding (concatMap, filter, map)
424-- >>> import Prelude hiding (concatMap, filter, map)
427
425
@@ -1042,7 +1040,7 @@ data ConcatMapState m sa a c
1042--
1040--
1043-- /Time: O(n^2) where @n@ is the number of compositions./
1041-- /Time: O(n^2) where @n@ is the number of compositions./
1044--
1042--
1045−-- See also: 'Streamly.Internal.Data.Stream.IsStream.foldIterateM', 'refold'
1043+-- See also: 'Streamly.Internal.Data.Stream.foldIterateM', 'refold'
1046--
1044--
1047-- @since 0.8.0
1045-- @since 0.8.0
1048--
1046--
core/src/Streamly/Internal/Data/Fold/Window.hs+1−1
@@ -73,7 +73,7 @@ import Prelude hiding (length, sum, minimum, maximum)
73-- >>> import qualified Streamly.Data.Fold as Fold
73-- >>> import qualified Streamly.Data.Fold as Fold
74-- >>> import qualified Streamly.Internal.Data.Fold.Window as FoldW
74-- >>> import qualified Streamly.Internal.Data.Fold.Window as FoldW
75-- >>> import qualified Streamly.Internal.Data.Ring.Foreign as Ring
75-- >>> import qualified Streamly.Internal.Data.Ring.Foreign as Ring
76−-- >>> import qualified Streamly.Prelude as Stream
76+-- >>> import qualified Streamly.Data.Stream as Stream
77-- >>> import Prelude hiding (length, sum, minimum, maximum)
77-- >>> import Prelude hiding (length, sum, minimum, maximum)
78
78
79-------------------------------------------------------------------------------
79-------------------------------------------------------------------------------
core/src/Streamly/Internal/Data/Parser.hs+4−4
@@ -266,8 +266,8 @@ import qualified Streamly.Internal.Data.Stream.Type as Stream
266-- >>> import Control.Applicative ((<|>))
266-- >>> import Control.Applicative ((<|>))
267-- >>> import Data.Char (isSpace)
267-- >>> import Data.Char (isSpace)
268-- >>> import qualified Data.Maybe as Maybe
268-- >>> import qualified Data.Maybe as Maybe
269−-- >>> import qualified Streamly.Prelude as Stream
269+-- >>> import qualified Streamly.Data.Stream as Stream
270−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream (parse, parseMany)
270+-- >>> import qualified Streamly.Internal.Data.Stream as Stream (parse, parseMany)
271-- >>> import qualified Streamly.Internal.Data.Fold as Fold
271-- >>> import qualified Streamly.Internal.Data.Fold as Fold
272-- >>> import qualified Streamly.Internal.Data.Parser as Parser
272-- >>> import qualified Streamly.Internal.Data.Parser as Parser
273
273
@@ -945,7 +945,7 @@ wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSpc =
945--
945--
946-- >>> :{
946-- >>> :{
947-- runGroupsBy eq =
947-- runGroupsBy eq =
948−-- Stream.toList
948+-- Stream.fold Fold.toList
949-- . Stream.parseMany (Parser.groupBy eq Fold.toList)
949-- . Stream.parseMany (Parser.groupBy eq Fold.toList)
950-- . Stream.fromList
950-- . Stream.fromList
951-- :}
951-- :}
@@ -979,7 +979,7 @@ groupBy eq = D.toParserK . D.groupBy eq
979--
979--
980-- >>> :{
980-- >>> :{
981-- runGroupsByRolling eq =
981-- runGroupsByRolling eq =
982−-- Stream.toList
982+-- Stream.fold Fold.toList
983-- . Stream.parseMany (Parser.groupByRolling eq Fold.toList)
983-- . Stream.parseMany (Parser.groupByRolling eq Fold.toList)
984-- . Stream.fromList
984-- . Stream.fromList
985-- :}
985-- :}
core/src/Streamly/Internal/Data/Parser/ParserD.hs+2−2
@@ -226,8 +226,8 @@ import Streamly.Internal.Data.Parser.ParserD.Type
226-- >>> :set -package streamly
226-- >>> :set -package streamly
227-- >>> import Prelude hiding ()
227-- >>> import Prelude hiding ()
228-- >>> import qualified Data.Maybe as Maybe
228-- >>> import qualified Data.Maybe as Maybe
229−-- >>> import qualified Streamly.Prelude as Stream
229+-- >>> import qualified Streamly.Data.Stream as Stream
230−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream
230+-- >>> import qualified Streamly.Internal.Data.Stream as Stream
231-- >>> import qualified Streamly.Data.Fold as Fold
231-- >>> import qualified Streamly.Data.Fold as Fold
232-- >>> import qualified Streamly.Internal.Data.Parser as Parser
232-- >>> import qualified Streamly.Internal.Data.Parser as Parser
233
233
core/src/Streamly/Internal/Data/Parser/ParserD/Type.hs+2−2
@@ -229,8 +229,8 @@ import Prelude hiding (concatMap, filter)
229-- >>> import Control.Applicative ((<|>))
229-- >>> import Control.Applicative ((<|>))
230-- >>> import Data.Bifunctor (second)
230-- >>> import Data.Bifunctor (second)
231-- >>> import Prelude hiding (concatMap)
231-- >>> import Prelude hiding (concatMap)
232−-- >>> import qualified Streamly.Prelude as Stream
232+-- >>> import qualified Streamly.Data.Stream as Stream
233−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream (parse)
233+-- >>> import qualified Streamly.Internal.Data.Stream as Stream (parse)
234-- >>> import qualified Streamly.Internal.Data.Parser as Parser
234-- >>> import qualified Streamly.Internal.Data.Parser as Parser
235-- >>> import qualified Streamly.Internal.Data.Parser.ParserD as ParserD
235-- >>> import qualified Streamly.Internal.Data.Parser.ParserD as ParserD
236
236
core/src/Streamly/Internal/Data/Refold/Type.hs+2−2
@@ -54,7 +54,7 @@ import Prelude hiding (take, iterate)
54-- >>> :set -package streamly
54-- >>> :set -package streamly
55-- >>> import qualified Streamly.Internal.Data.Refold.Type as Refold
55-- >>> import qualified Streamly.Internal.Data.Refold.Type as Refold
56-- >>> import qualified Streamly.Internal.Data.Fold.Type as Fold
56-- >>> import qualified Streamly.Internal.Data.Fold.Type as Fold
57−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream
57+-- >>> import qualified Streamly.Internal.Data.Stream as Stream
58
58
59-- All folds in the Fold module should be implemented using Refolds.
59-- All folds in the Fold module should be implemented using Refolds.
60--
60--
@@ -145,7 +145,7 @@ drainBy f = Refold step inject extract
145
145
146-- | Append the elements of an input stream to a provided starting value.
146-- | Append the elements of an input stream to a provided starting value.
147--
147--
148−-- >>> stream = Stream.map Data.Monoid.Sum $ Stream.enumerateFromTo 1 10
148+-- >>> stream = fmap Data.Monoid.Sum $ Stream.enumerateFromTo 1 10
149-- >>> Stream.fold (Fold.fromRefold Refold.sconcat 10) stream
149-- >>> Stream.fold (Fold.fromRefold Refold.sconcat 10) stream
150-- Sum {getSum = 65}
150-- Sum {getSum = 65}
151--
151--
core/src/Streamly/Internal/Data/Stream/Serial.hs+2−2
@@ -9,7 +9,7 @@
9--
9--
10-- To run examples in this module:
10-- To run examples in this module:
11--
11--
12−-- >>> import qualified Streamly.Prelude as Stream
12+-- >>> import qualified Streamly.Data.Stream as Stream
13--
13--
14module Streamly.Internal.Data.Stream.Serial
14module Streamly.Internal.Data.Stream.Serial
15 (
15 (
@@ -44,7 +44,7 @@ import qualified Streamly.Internal.Data.Stream as Stream
44import Prelude hiding (map)
44import Prelude hiding (map)
45
45
46-- $setup
46-- $setup
47−-- >>> import qualified Streamly.Prelude as Stream
47+-- >>> import qualified Streamly.Data.Stream as Stream
48
48
49------------------------------------------------------------------------------
49------------------------------------------------------------------------------
50-- SerialT
50-- SerialT
core/src/Streamly/Internal/Data/Stream/StreamD/Exception.hs+11−11
@@ -173,7 +173,7 @@ gbracket bef aft onExc onGC ftry action =
173 Skip s -> return $ Skip (GBracketIOException (Stream step1 s))
173 Skip s -> return $ Skip (GBracketIOException (Stream step1 s))
174 Stop -> return Stop
174 Stop -> return Stop
175
175
176−-- | See 'Streamly.Internal.Data.Stream.IsStream.before'.
176+-- | See 'Streamly.Internal.Data.Stream.before'.
177--
177--
178{-# INLINE_NORMAL before #-}
178{-# INLINE_NORMAL before #-}
179before :: Monad m => m b -> Stream m a -> Stream m a
179before :: Monad m => m b -> Stream m a -> Stream m a
@@ -191,7 +191,7 @@ before action (Stream step state) = Stream step' Nothing
191 Skip s -> return $ Skip (Just s)
191 Skip s -> return $ Skip (Just s)
192 Stop -> return Stop
192 Stop -> return Stop
193
193
194−-- | See 'Streamly.Internal.Data.Stream.IsStream.after_'.
194+-- | See 'Streamly.Internal.Data.Stream.after_'.
195--
195--
196{-# INLINE_NORMAL after_ #-}
196{-# INLINE_NORMAL after_ #-}
197after_ :: Monad m => m b -> Stream m a -> Stream m a
197after_ :: Monad m => m b -> Stream m a -> Stream m a
@@ -207,7 +207,7 @@ after_ action (Stream step state) = Stream step' state
207 Skip s -> return $ Skip s
207 Skip s -> return $ Skip s
208 Stop -> action >> return Stop
208 Stop -> action >> return Stop
209
209
210−-- | See 'Streamly.Internal.Data.Stream.IsStream.after'.
210+-- | See 'Streamly.Internal.Data.Stream.after'.
211--
211--
212{-# INLINE_NORMAL after #-}
212{-# INLINE_NORMAL after #-}
213after :: MonadRunInIO m
213after :: MonadRunInIO m
@@ -232,7 +232,7 @@ after action (Stream step state) = Stream step' Nothing
232-- XXX For high performance error checks in busy streams we may need another
232-- XXX For high performance error checks in busy streams we may need another
233-- Error constructor in step.
233-- Error constructor in step.
234--
234--
235−-- | See 'Streamly.Internal.Data.Stream.IsStream.onException'.
235+-- | See 'Streamly.Internal.Data.Stream.onException'.
236--
236--
237{-# INLINE_NORMAL onException #-}
237{-# INLINE_NORMAL onException #-}
238onException :: MonadCatch m => m b -> Stream m a -> Stream m a
238onException :: MonadCatch m => m b -> Stream m a -> Stream m a
@@ -258,7 +258,7 @@ _onException action (Stream step state) = Stream step' state
258 Skip s -> return $ Skip s
258 Skip s -> return $ Skip s
259 Stop -> return Stop
259 Stop -> return Stop
260
260
261−-- | See 'Streamly.Internal.Data.Stream.IsStream.bracket_'.
261+-- | See 'Streamly.Internal.Data.Stream.bracket_'.
262--
262--
263{-# INLINE_NORMAL bracket_ #-}
263{-# INLINE_NORMAL bracket_ #-}
264bracket_ :: MonadCatch m
264bracket_ :: MonadCatch m
@@ -270,7 +270,7 @@ bracket_ bef aft =
270 (\a (e :: SomeException) _ -> nilM (aft a >> MC.throwM e))
270 (\a (e :: SomeException) _ -> nilM (aft a >> MC.throwM e))
271 (inline MC.try)
271 (inline MC.try)
272
272
273−-- | See 'Streamly.Internal.Data.Stream.IsStream.bracket'.
273+-- | See 'Streamly.Internal.Data.Stream.bracket'.
274--
274--
275{-# INLINE_NORMAL bracket' #-}
275{-# INLINE_NORMAL bracket' #-}
276bracket' :: (MonadAsync m, MonadCatch m) =>
276bracket' :: (MonadAsync m, MonadCatch m) =>
@@ -314,13 +314,13 @@ _bracket bef aft bet = Stream step' BracketInit
314 Skip s -> return $ Skip (BracketRun (Stream step s) v)
314 Skip s -> return $ Skip (BracketRun (Stream step s) v)
315 Stop -> aft v >> return Stop
315 Stop -> aft v >> return Stop
316
316
317−-- | See 'Streamly.Internal.Data.Stream.IsStream.finally_'.
317+-- | See 'Streamly.Internal.Data.Stream.finally_'.
318--
318--
319{-# INLINE finally_ #-}
319{-# INLINE finally_ #-}
320finally_ :: MonadCatch m => m b -> Stream m a -> Stream m a
320finally_ :: MonadCatch m => m b -> Stream m a -> Stream m a
321finally_ action xs = bracket_ (return ()) (const action) (const xs)
321finally_ action xs = bracket_ (return ()) (const action) (const xs)
322
322
323−-- | See 'Streamly.Internal.Data.Stream.IsStream.finally'.
323+-- | See 'Streamly.Internal.Data.Stream.finally'.
324--
324--
325-- finally action xs = after action $ onException action xs
325-- finally action xs = after action $ onException action xs
326--
326--
@@ -329,7 +329,7 @@ finally :: (MonadAsync m, MonadCatch m) => m b -> Stream m a -> Stream m a
329finally action xs = bracket' (return ()) act act act (const xs)
329finally action xs = bracket' (return ()) act act act (const xs)
330 where act _ = action
330 where act _ = action
331
331
332−-- | See 'Streamly.Internal.Data.Stream.IsStream.ghandle'.
332+-- | See 'Streamly.Internal.Data.Stream.ghandle'.
333--
333--
334{-# INLINE_NORMAL ghandle #-}
334{-# INLINE_NORMAL ghandle #-}
335ghandle :: (MonadCatch m, Exception e)
335ghandle :: (MonadCatch m, Exception e)
@@ -337,7 +337,7 @@ ghandle :: (MonadCatch m, Exception e)
337ghandle f stream =
337ghandle f stream =
338 gbracket_ (return ()) return (const f) (inline MC.try) (const stream)
338 gbracket_ (return ()) return (const f) (inline MC.try) (const stream)
339
339
340−-- | See 'Streamly.Internal.Data.Stream.IsStream.handle'.
340+-- | See 'Streamly.Internal.Data.Stream.handle'.
341--
341--
342{-# INLINE_NORMAL handle #-}
342{-# INLINE_NORMAL handle #-}
343handle :: (MonadCatch m, Exception e)
343handle :: (MonadCatch m, Exception e)
@@ -375,7 +375,7 @@ data RetryState emap s1 s2
375 = RetryWithMap emap s1
375 = RetryWithMap emap s1
376 | RetryDefault s2
376 | RetryDefault s2
377
377
378−-- | See 'Streamly.Internal.Data.Stream.IsStream.retry'
378+-- | See 'Streamly.Internal.Data.Stream.retry'
379--
379--
380{-# INLINE_NORMAL retry #-}
380{-# INLINE_NORMAL retry #-}
381retry
381retry
core/src/Streamly/Internal/Data/Stream/StreamD/Nesting.hs+4−1
@@ -555,7 +555,10 @@ data ConcatUnfoldInterleaveState o i =
555-- of pairing up the streams we just need to go yielding one element from each
555-- of pairing up the streams we just need to go yielding one element from each
556-- stream and storing the remaining streams and then keep doing rounds through
556-- stream and storing the remaining streams and then keep doing rounds through
557-- those in a round robin fashion. This would be much like wAsync.
557-- those in a round robin fashion. This would be much like wAsync.
558−
558+--
559+-- See 'Streamly.Internal.Data.Stream.unfoldInterleave' documentation for more
560+-- details.
561+--
559{-# INLINE_NORMAL unfoldManyInterleave #-}
562{-# INLINE_NORMAL unfoldManyInterleave #-}
560unfoldManyInterleave :: Monad m => Unfold m a b -> Stream m a -> Stream m b
563unfoldManyInterleave :: Monad m => Unfold m a b -> Stream m a -> Stream m b
561unfoldManyInterleave (Unfold istep inject) (Stream ostep ost) =
564unfoldManyInterleave (Unfold istep inject) (Stream ostep ost) =
core/src/Streamly/Internal/Data/Stream/StreamK/Type.hs+1−1
@@ -1044,7 +1044,7 @@ concatMap_ f xs = buildS
1044 (\c n -> foldrSShared (\x b -> foldrSShared c b (unShare $ f x)) n xs)
1044 (\c n -> foldrSShared (\x b -> foldrSShared c b (unShare $ f x)) n xs)
1045-}
1045-}
1046
1046
1047−-- | See 'Streamly.Internal.Data.Stream.IsStream.concatPairsWith' for
1047+-- | See 'Streamly.Internal.Data.Stream.concatPairsWith' for
1048-- documentation.
1048-- documentation.
1049--
1049--
1050{-# INLINE concatPairsWith #-}
1050{-# INLINE concatPairsWith #-}
core/src/Streamly/Internal/Data/Stream/Top.hs+8−8
@@ -74,8 +74,8 @@ import Prelude hiding (filter, zipWith, concatMap, concat)
74-- $setup
74-- $setup
75-- >>> :m
75-- >>> :m
76-- >>> import Prelude hiding (filter, zipWith, concatMap, concat)
76-- >>> import Prelude hiding (filter, zipWith, concatMap, concat)
77−-- >>> import qualified Streamly.Prelude as Stream
77+-- >>> import qualified Streamly.Internal.Data.Fold as Fold
78−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream
78+-- >>> import qualified Streamly.Internal.Data.Stream as Stream
79
79
80------------------------------------------------------------------------------
80------------------------------------------------------------------------------
81-- Sampling
81-- Sampling
@@ -87,7 +87,7 @@ import Prelude hiding (filter, zipWith, concatMap, concat)
87-- | @sampleFromthen offset stride@ samples the element at @offset@ index and
87-- | @sampleFromthen offset stride@ samples the element at @offset@ index and
88-- then every element at strides of @stride@.
88-- then every element at strides of @stride@.
89--
89--
90−-- >>> Stream.toList $ Stream.sampleFromThen 2 3 $ Stream.enumerateFromTo 0 10
90+-- >>> Stream.fold Fold.toList $ Stream.sampleFromThen 2 3 $ Stream.enumerateFromTo 0 10
91-- [2,5,8]
91-- [2,5,8]
92--
92--
93-- /Pre-release/
93-- /Pre-release/
@@ -489,15 +489,15 @@ mergeOuterJoin _eq _s1 _s2 = undefined
489-- | 'intersectBy' is essentially a filtering operation that retains only those
489-- | 'intersectBy' is essentially a filtering operation that retains only those
490-- elements in the first stream that are present in the second stream.
490-- elements in the first stream that are present in the second stream.
491--
491--
492−-- >>> Stream.toList $ Stream.intersectBy (==) (Stream.fromList [1,2,2,4]) (Stream.fromList [2,1,1,3])
492+-- >>> Stream.fold Fold.toList $ Stream.intersectBy (==) (Stream.fromList [1,2,2,4]) (Stream.fromList [2,1,1,3])
493-- [1,2,2]
493-- [1,2,2]
494--
494--
495−-- >>> Stream.toList $ Stream.intersectBy (==) (Stream.fromList [2,1,1,3]) (Stream.fromList [1,2,2,4])
495+-- >>> Stream.fold Fold.toList $ Stream.intersectBy (==) (Stream.fromList [2,1,1,3]) (Stream.fromList [1,2,2,4])
496-- [2,1,1]
496-- [2,1,1]
497--
497--
498-- 'intersectBy' is similar to but not the same as 'joinInner':
498-- 'intersectBy' is similar to but not the same as 'joinInner':
499--
499--
500−-- >>> Stream.toList $ fmap fst $ Stream.joinInner (==) (Stream.fromList [1,2,2,4]) (Stream.fromList [2,1,1,3])
500+-- >>> Stream.fold Fold.toList $ fmap fst $ Stream.joinInner (==) (Stream.fromList [1,2,2,4]) (Stream.fromList [2,1,1,3])
501-- [1,1,2,2]
501-- [1,1,2,2]
502--
502--
503-- Space: O(n) where @n@ is the number of elements in the second stream.
503-- Space: O(n) where @n@ is the number of elements in the second stream.
@@ -537,7 +537,7 @@ intersectBySorted eq s1 =
537-- present in the second stream. If an element occurs multiple times in the
537-- present in the second stream. If an element occurs multiple times in the
538-- second stream as many occurrences of it are deleted from the first stream.
538-- second stream as many occurrences of it are deleted from the first stream.
539--
539--
540−-- >>> Stream.toList $ Stream.differenceBy (==) (Stream.fromList [1,2,2]) (Stream.fromList [1,2,3])
540+-- >>> Stream.fold Fold.toList $ Stream.differenceBy (==) (Stream.fromList [1,2,2]) (Stream.fromList [1,2,3])
541-- [2]
541-- [2]
542--
542--
543-- The following laws hold:
543-- The following laws hold:
@@ -584,7 +584,7 @@ mergeDifferenceBy _eq _s1 _s2 = undefined
584-- occurrences of elements from the second stream that are not already present
584-- occurrences of elements from the second stream that are not already present
585-- in the first stream.
585-- in the first stream.
586--
586--
587−-- >>> Stream.toList $ Stream.unionBy (==) (Stream.fromList [1,2,2,4]) (Stream.fromList [1,1,2,3])
587+-- >>> Stream.fold Fold.toList $ Stream.unionBy (==) (Stream.fromList [1,2,2,4]) (Stream.fromList [1,1,2,3])
588-- [1,2,2,4,3]
588-- [1,2,2,4,3]
589--
589--
590-- Equivalent to the following except that @s1@ is evaluated only once:
590-- Equivalent to the following except that @s1@ is evaluated only once:
core/src/Streamly/Internal/Data/Unfold.hs+2−2
@@ -118,7 +118,7 @@ module Streamly.Internal.Data.Unfold
118
118
119 -- * Unfolds
119 -- * Unfolds
120 -- One to one correspondence with
120 -- One to one correspondence with
121− -- "Streamly.Internal.Data.Stream.IsStream.Generate"
121+ -- "Streamly.Internal.Data.Stream.Generate"
122 -- ** Basic Constructors
122 -- ** Basic Constructors
123 , mkUnfoldM
123 , mkUnfoldM
124 , mkUnfoldrM
124 , mkUnfoldrM
@@ -297,7 +297,7 @@ import Foreign.Ptr
297-- $setup
297-- $setup
298-- >>> import qualified Streamly.Data.Fold as Fold
298-- >>> import qualified Streamly.Data.Fold as Fold
299-- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
299-- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
300−-- >>> import qualified Streamly.Prelude as Stream
300+-- >>> import qualified Streamly.Data.Stream as Stream
301
301
302
302
303-- | Convert an 'Unfold' into an unfold accepting a tuple as an argument,
303-- | Convert an 'Unfold' into an unfold accepting a tuple as an argument,
core/src/Streamly/Internal/Data/Unfold/Enumeration.hs+20−19
@@ -73,7 +73,8 @@ import Prelude
73
73
74-- $setup
74-- $setup
75-- >>> :m
75-- >>> :m
76−-- >>> import qualified Streamly.Prelude as Stream
76+-- >>> import qualified Streamly.Data.Fold as Fold
77+-- >>> import qualified Streamly.Data.Stream as Stream
77-- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
78-- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
78-- >>> import Streamly.Internal.Data.Unfold.Type
79-- >>> import Streamly.Internal.Data.Unfold.Type
79-- >>> import Data.Word
80-- >>> import Data.Word
@@ -87,7 +88,7 @@ import Prelude
87-- the value overflows it keeps enumerating in a cycle:
88-- the value overflows it keeps enumerating in a cycle:
88--
89--
89-- @
90-- @
90−-- >>> Stream.toList $ Stream.take 10 $ Stream.unfold Unfold.enumerateFromStepNum (255::Word8,1)
91+-- >>> Stream.fold Fold.toList $ Stream.take 10 $ Stream.unfold Unfold.enumerateFromStepNum (255::Word8,1)
91-- [255,0,1,2,3,4,5,6,7,8]
92-- [255,0,1,2,3,4,5,6,7,8]
92--
93--
93-- @
94-- @
@@ -124,7 +125,7 @@ enumerateFromStepNum = Unfold step inject
124--
125--
125-- Example:
126-- Example:
126-- @
127-- @
127−-- >>> Stream.toList $ Stream.take 10 $ Stream.unfold enumerateFromThenNum (255::Word8,0)
128+-- >>> Stream.fold Fold.toList $ Stream.take 10 $ Stream.unfold enumerateFromThenNum (255::Word8,0)
128-- [255,0,1,2,3,4,5,6,7,8]
129-- [255,0,1,2,3,4,5,6,7,8]
129--
130--
130-- @
131-- @
@@ -151,7 +152,7 @@ enumerateFromThenNum =
151--
152--
152-- @
153-- @
153-- >>> enumerateFromNum = lmap (\from -> (from, 1)) Unfold.enumerateFromStepNum
154-- >>> enumerateFromNum = lmap (\from -> (from, 1)) Unfold.enumerateFromStepNum
154−-- >>> Stream.toList $ Stream.take 6 $ Stream.unfold enumerateFromNum (0.9)
155+-- >>> Stream.fold Fold.toList $ Stream.take 6 $ Stream.unfold enumerateFromNum (0.9)
155-- [0.9,1.9,2.9,3.9,4.9,5.9]
156-- [0.9,1.9,2.9,3.9,4.9,5.9]
156--
157--
157-- @
158-- @
@@ -161,7 +162,7 @@ enumerateFromThenNum =
161--
162--
162-- @
163-- @
163-- >>> enumerateFromNum = lmap (\from -> (from, from + 1)) Unfold.enumerateFromThenNum
164-- >>> enumerateFromNum = lmap (\from -> (from, from + 1)) Unfold.enumerateFromThenNum
164−-- >>> Stream.toList $ Stream.take 6 $ Stream.unfold enumerateFromNum (0.9)
165+-- >>> Stream.fold Fold.toList $ Stream.take 6 $ Stream.unfold enumerateFromNum (0.9)
165-- [0.9,1.9,2.9,3.8999999999999995,4.8999999999999995,5.8999999999999995]
166-- [0.9,1.9,2.9,3.8999999999999995,4.8999999999999995,5.8999999999999995]
166--
167--
167-- @
168-- @
@@ -283,7 +284,7 @@ enumerateFromThenFractional = enumerateFromThenNum
283-- specified upper limit rounded to the nearest integral value:
284-- specified upper limit rounded to the nearest integral value:
284--
285--
285-- @
286-- @
286−-- >>> Stream.toList $ Stream.unfold Unfold.enumerateFromToFractional (0.1, 6.3)
287+-- >>> Stream.fold Fold.toList $ Stream.unfold Unfold.enumerateFromToFractional (0.1, 6.3)
287-- [0.1,1.1,2.1,3.1,4.1,5.1,6.1]
288-- [0.1,1.1,2.1,3.1,4.1,5.1,6.1]
288--
289--
289-- @
290-- @
@@ -388,11 +389,11 @@ class Enum a => Enumerable a where
388 -- @from@, enumerating up to 'maxBound' when the type is 'Bounded' or
389 -- @from@, enumerating up to 'maxBound' when the type is 'Bounded' or
389 -- generating an infinite stream when the type is not 'Bounded'.
390 -- generating an infinite stream when the type is not 'Bounded'.
390 --
391 --
391− -- >>> import qualified Streamly.Prelude as Stream
392+ -- >>> import qualified Streamly.Data.Stream as Stream
392 -- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
393 -- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
393 --
394 --
394 -- @
395 -- @
395− -- >>> Stream.toList $ Stream.take 4 $ Stream.unfold Unfold.enumerateFrom (0 :: Int)
396+ -- >>> Stream.fold Fold.toList $ Stream.take 4 $ Stream.unfold Unfold.enumerateFrom (0 :: Int)
396 -- [0,1,2,3]
397 -- [0,1,2,3]
397 --
398 --
398 -- @
399 -- @
@@ -401,7 +402,7 @@ class Enum a => Enumerable a where
401 -- overflow or underflow checks are performed.
402 -- overflow or underflow checks are performed.
402 --
403 --
403 -- @
404 -- @
404− -- >>> Stream.toList $ Stream.take 4 $ Stream.unfold Unfold.enumerateFrom 1.1
405+ -- >>> Stream.fold Fold.toList $ Stream.take 4 $ Stream.unfold Unfold.enumerateFrom 1.1
405 -- [1.1,2.1,3.1,4.1]
406 -- [1.1,2.1,3.1,4.1]
406 --
407 --
407 -- @
408 -- @
@@ -414,11 +415,11 @@ class Enum a => Enumerable a where
414 -- @from@, enumerating the type up to the value @to@. If @to@ is smaller than
415 -- @from@, enumerating the type up to the value @to@. If @to@ is smaller than
415 -- @from@ then an empty stream is returned.
416 -- @from@ then an empty stream is returned.
416 --
417 --
417− -- >>> import qualified Streamly.Prelude as Stream
418+ -- >>> import qualified Streamly.Data.Stream as Stream
418 -- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
419 -- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
419 --
420 --
420 -- @
421 -- @
421− -- >>> Stream.toList $ Stream.unfold Unfold.enumerateFromTo (0, 4)
422+ -- >>> Stream.fold Fold.toList $ Stream.unfold Unfold.enumerateFromTo (0, 4)
422 -- [0,1,2,3,4]
423 -- [0,1,2,3,4]
423 --
424 --
424 -- @
425 -- @
@@ -427,10 +428,10 @@ class Enum a => Enumerable a where
427 -- value after rounding to the nearest integral value.
428 -- value after rounding to the nearest integral value.
428 --
429 --
429 -- @
430 -- @
430− -- >>> Stream.toList $ Stream.unfold Unfold.enumerateFromTo (1.1, 4)
431+ -- >>> Stream.fold Fold.toList $ Stream.unfold Unfold.enumerateFromTo (1.1, 4)
431 -- [1.1,2.1,3.1,4.1]
432 -- [1.1,2.1,3.1,4.1]
432 --
433 --
433− -- >>> Stream.toList $ Stream.unfold Unfold.enumerateFromTo (1.1, 4.6)
434+ -- >>> Stream.fold Fold.toList $ Stream.unfold Unfold.enumerateFromTo (1.1, 4.6)
434 -- [1.1,2.1,3.1,4.1,5.1]
435 -- [1.1,2.1,3.1,4.1,5.1]
435 --
436 --
436 -- @
437 -- @
@@ -444,14 +445,14 @@ class Enum a => Enumerable a where
444 -- after @from@. For 'Bounded' types the stream ends when 'maxBound' is
445 -- after @from@. For 'Bounded' types the stream ends when 'maxBound' is
445 -- reached, for unbounded types it keeps enumerating infinitely.
446 -- reached, for unbounded types it keeps enumerating infinitely.
446 --
447 --
447− -- >>> import qualified Streamly.Prelude as Stream
448+ -- >>> import qualified Streamly.Data.Stream as Stream
448 -- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
449 -- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
449 --
450 --
450 -- @
451 -- @
451− -- >>> Stream.toList $ Stream.take 4 $ Stream.unfold Unfold.enumerateFromThen (0, 2)
452+ -- >>> Stream.fold Fold.toList $ Stream.take 4 $ Stream.unfold Unfold.enumerateFromThen (0, 2)
452 -- [0,2,4,6]
453 -- [0,2,4,6]
453 --
454 --
454− -- >>> Stream.toList $ Stream.take 4 $ Stream.unfold Unfold.enumerateFromThen (0,(-2))
455+ -- >>> Stream.fold Fold.toList $ Stream.take 4 $ Stream.unfold Unfold.enumerateFromThen (0,(-2))
455 -- [0,-2,-4,-6]
456 -- [0,-2,-4,-6]
456 --
457 --
457 -- @
458 -- @
@@ -464,14 +465,14 @@ class Enum a => Enumerable a where
464 -- @to@. Enumeration can occur downwards or upwards depending on whether @then@
465 -- @to@. Enumeration can occur downwards or upwards depending on whether @then@
465 -- comes before or after @from@.
466 -- comes before or after @from@.
466 --
467 --
467− -- >>> import qualified Streamly.Prelude as Stream
468+ -- >>> import qualified Streamly.Data.Stream as Stream
468 -- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
469 -- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
469 --
470 --
470 -- @
471 -- @
471− -- >>> Stream.toList $ Stream.unfold Unfold.enumerateFromThenTo (0, 2, 6)
472+ -- >>> Stream.fold Fold.toList $ Stream.unfold Unfold.enumerateFromThenTo (0, 2, 6)
472 -- [0,2,4,6]
473 -- [0,2,4,6]
473 --
474 --
474− -- >>> Stream.toList $ Stream.unfold Unfold.enumerateFromThenTo (0, (-2), (-6))
475+ -- >>> Stream.fold Fold.toList $ Stream.unfold Unfold.enumerateFromThenTo (0, (-2), (-6))
475 -- [0,-2,-4,-6]
476 -- [0,-2,-4,-6]
476 --
477 --
477 -- @
478 -- @
core/src/Streamly/Internal/Data/Unfold/Type.hs+5−5
@@ -8,7 +8,7 @@
8--
8--
9-- To run the examples in this module:
9-- To run the examples in this module:
10--
10--
11−-- >>> import qualified Streamly.Prelude as Stream
11+-- >>> import qualified Streamly.Data.Stream as Stream
12-- >>> import qualified Streamly.Data.Fold as Fold
12-- >>> import qualified Streamly.Data.Fold as Fold
13-- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
13-- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
14
14
@@ -85,7 +85,7 @@ import Streamly.Internal.Data.Stream.StreamD.Step (Step(..))
85import Prelude hiding (map, mapM, concatMap, zipWith, takeWhile)
85import Prelude hiding (map, mapM, concatMap, zipWith, takeWhile)
86
86
87-- $setup
87-- $setup
88−-- >>> import qualified Streamly.Prelude as Stream
88+-- >>> import qualified Streamly.Data.Stream as Stream
89-- >>> import qualified Streamly.Data.Fold as Fold
89-- >>> import qualified Streamly.Data.Fold as Fold
90-- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
90-- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
91
91
@@ -549,7 +549,7 @@ apply u1 u2 = fmap (\(a, b) -> a b) (cross u1 u2)
549--
549--
550-- >>> rlist = Unfold.lmap fst Unfold.fromList
550-- >>> rlist = Unfold.lmap fst Unfold.fromList
551-- >>> llist = Unfold.lmap snd Unfold.fromList
551-- >>> llist = Unfold.lmap snd Unfold.fromList
552−-- >>> Stream.toList $ Stream.unfold ((,) <$> rlist <*> llist) ([1,2],[3,4])
552+-- >>> Stream.fold Fold.toList $ Stream.unfold ((,) <$> rlist <*> llist) ([1,2],[3,4])
553-- [(1,3),(1,4),(2,3),(2,4)]
553-- [(1,3),(1,4),(2,3),(2,4)]
554--
554--
555instance Monad m => Applicative (Unfold m a) where
555instance Monad m => Applicative (Unfold m a) where
@@ -635,7 +635,7 @@ bind = flip concatMap
635-- y <- Unfold.enumerateFromToIntegral x
635-- y <- Unfold.enumerateFromToIntegral x
636-- return (x, y)
636-- return (x, y)
637-- :}
637-- :}
638−-- >>> Stream.toList $ Stream.unfold u 1
638+-- >>> Stream.fold Fold.toList $ Stream.unfold u 1
639-- [(1,1),(2,1),(2,2),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3),(4,4)]
639-- [(1,1),(2,1),(2,2),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3),(4,4)]
640--
640--
641instance Monad m => Monad (Unfold m a) where
641instance Monad m => Monad (Unfold m a) where
@@ -850,7 +850,7 @@ data ManyInterleaveState o i =
850 | ManyInterleaveInnerL [i] [i]
850 | ManyInterleaveInnerL [i] [i]
851 | ManyInterleaveInnerR [i] [i]
851 | ManyInterleaveInnerR [i] [i]
852
852
853−-- | 'Streamly.Internal.Data.Stream.IsStream.unfoldManyInterleave' for
853+-- | 'Streamly.Internal.Data.Stream.unfoldManyInterleave' for
854-- documentation and notes.
854-- documentation and notes.
855--
855--
856-- This is almost identical to unfoldManyInterleave in StreamD module.
856-- This is almost identical to unfoldManyInterleave in StreamD module.