on master help sign in
Make streamly-core free from IsStream (#1796)
commit7278ecb63e7f048a5265a8345d3f8ec51f4d7bc9 authorRanjeet Ranjan <ranjeetr@composewell.com> dateTue 23 Aug 2022, 15:11 (4 years ago) parent0b4a300
20 files changed+84−83
core/src/Streamly/Data/Fold.hs+6−6 core/src/Streamly/Data/Fold/Tee.hs+1−1 core/src/Streamly/Internal/Data/Array/Mut/Type.hs+1−1 core/src/Streamly/Internal/Data/Array/Stream/Fold/Foreign.hs+2−2 core/src/Streamly/Internal/Data/Array/Unboxed/Mut/Type.hs+1−1 core/src/Streamly/Internal/Data/Fold.hs+7−8 core/src/Streamly/Internal/Data/Fold/Type.hs+2−4 core/src/Streamly/Internal/Data/Fold/Window.hs+1−1 core/src/Streamly/Internal/Data/Parser.hs+4−4 core/src/Streamly/Internal/Data/Parser/ParserD.hs+2−2 core/src/Streamly/Internal/Data/Parser/ParserD/Type.hs+2−2 core/src/Streamly/Internal/Data/Refold/Type.hs+2−2 core/src/Streamly/Internal/Data/Stream/Serial.hs+2−2 core/src/Streamly/Internal/Data/Stream/StreamD/Exception.hs+11−11 core/src/Streamly/Internal/Data/Stream/StreamD/Nesting.hs+4−1 core/src/Streamly/Internal/Data/Stream/StreamK/Type.hs+1−1 core/src/Streamly/Internal/Data/Stream/Top.hs+8−8 core/src/Streamly/Internal/Data/Unfold.hs+2−2 core/src/Streamly/Internal/Data/Unfold/Enumeration.hs+20−19 core/src/Streamly/Internal/Data/Unfold/Type.hs+5−5
core/src/Streamly/Data/Fold.hs+6−6
@@ -12,7 +12,7 @@
1212--
1313-- >>> import Data.Function ((&))
1414-- >>> import qualified Streamly.Data.Fold as Fold
15−-- >>> import qualified Streamly.Prelude as Stream
15+-- >>> import qualified Streamly.Data.Stream as Stream
1616--
1717-- For example, a 'sum' Fold represents adding the input to the accumulated
1818-- sum. A fold driver e.g. 'Streamly.Prelude.fold' pushes values from a stream
@@ -59,7 +59,7 @@
5959-- folds. For example, to count even and odd numbers in a stream:
6060--
6161-- >>> 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]
6363-- >>> countEven = fmap (("Even " ++) . show) Fold.length
6464-- >>> countOdd = fmap (("Odd " ++) . show) Fold.length
6565-- >>> f = Fold.partition countEven countOdd
@@ -78,7 +78,7 @@
7878-- of fold results. To split a stream on newlines:
7979--
8080-- >>> 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"
8282-- ["Hello there!\n","How are you\n"]
8383--
8484-- Similarly, we can split the input of a fold too:
@@ -102,8 +102,8 @@
102102-- >>> :{
103103-- f stream =
104104-- Stream.filter odd stream
105−-- & Stream.map (+1)
106−-- & Stream.sum
105+-- & fmap (+1)
106+-- & Stream.fold Fold.sum
107107-- :}
108108--
109109-- >>> f $ Stream.fromList [1..100 :: Int]
@@ -286,4 +286,4 @@ import Streamly.Internal.Data.Fold
286286-- $setup
287287-- >>> import Data.Function ((&))
288288-- >>> 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 @@
1515-- through the stream twice:
1616--
1717-- >>> import Streamly.Data.Fold.Tee (Tee(..))
18−-- >>> import qualified Streamly.Prelude as Stream
18+-- >>> import qualified Streamly.Data.Stream as Stream
1919-- >>> import qualified Streamly.Data.Fold as Fold
2020--
2121-- >>> 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)
181181-- >>> :m
182182-- >>> :set -package streamly
183183-- >>> 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
185185-- >>> import qualified Streamly.Internal.Data.Stream.StreamD as StreamD
186186-- >>> import qualified Streamly.Internal.Data.Fold as Fold
187187-- >>> 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 @@
2020-- >>> import qualified Streamly.Data.Fold as Fold
2121-- >>> import qualified Streamly.Internal.Data.Array.Stream.Foreign as ArrayStream
2222-- >>> import qualified Streamly.Internal.Data.Array.Stream.Fold.Foreign as ArrayFold
23−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream (arraysOf)
24−-- >>> import qualified Streamly.Prelude as Stream
23+-- >>> import qualified Streamly.Internal.Data.Stream as Stream (arraysOf)
24+-- >>> import qualified Streamly.Data.Stream as Stream
2525--
2626-- >>> f = ArrayFold.fromFold (Fold.take 7 Fold.toList)
2727-- >>> 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
270270-- $setup
271271-- >>> :m
272272-- >>> 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
274274-- >>> import qualified Streamly.Internal.Data.Stream.StreamD as StreamD
275275-- >>> import qualified Streamly.Internal.Data.Fold as Fold
276276-- >>> 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
339339-- >>> :m
340340-- >>> :set -package streamly
341341-- >>> import Prelude hiding (break, map, span, splitAt)
342−-- >>> import qualified Streamly.Prelude as Stream
343−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream (catMaybes, parse, foldMany)
342+-- >>> import qualified Streamly.Data.Stream as Stream
344343-- >>> import qualified Streamly.Data.Fold as Fold
345344-- >>> import qualified Streamly.Internal.Data.Fold as Fold
346345-- >>> import qualified Streamly.Internal.Data.Fold.Type as Fold
@@ -598,7 +597,7 @@ foldFilter f1 f2 = many f1 (catMaybes f2)
598597-- returns 'Nothing' for any other occurrences.
599598--
600599-- >>> 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
602601-- [1,2,3,4,5,7]
603602--
604603-- /Pre-release/
@@ -990,7 +989,7 @@ rollingMapM f = Fold step initial extract
990989
991990-- | Append the elements of an input stream to a provided starting value.
992991--
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)
994993-- Sum {getSum = 65}
995994--
996995-- @
@@ -1005,7 +1004,7 @@ sconcat = foldl' (<>)
10051004-- | Fold an input stream consisting of monoidal elements using 'mappend'
10061005-- and 'mempty'.
10071006--
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)
10091008-- Sum {getSum = 55}
10101009--
10111010-- > mconcat = Fold.sconcat mempty
@@ -1404,7 +1403,7 @@ splitAt n fld = serialWith (,) (take n fld)
14041403-- >>> Stream.fold (Fold.takeEndBy_ (== '\n') Fold.toList) $ Stream.fromList "hello\nthere\n"
14051404-- "hello"
14061405--
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"
14081407-- ["hello","there"]
14091408--
14101409-- > Stream.splitOnSuffix p f = Stream.foldMany (Fold.takeEndBy_ p f)
@@ -1431,7 +1430,7 @@ takeEndBy_ predicate (Fold fstep finitial fextract) =
14311430-- >>> Stream.fold (Fold.takeEndBy (== '\n') Fold.toList) $ Stream.fromList "hello\nthere\n"
14321431-- "hello\n"
14331432--
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"
14351434-- ["hello\n","there\n"]
14361435--
14371436-- > Stream.splitWithSuffix p f = Stream.foldMany (Fold.takeEndBy p f)
@@ -1479,7 +1478,7 @@ data SplitOnSeqState acc a rb rh w ck =
14791478-- >>> Stream.fold f s
14801479-- "hello there"
14811480--
1482−-- >>> Stream.toList $ Stream.foldMany f s
1481+-- >>> Stream.fold Fold.toList $ Stream.foldMany f s
14831482-- ["hello there",". How are"," you?"]
14841483--
14851484-- /Pre-release/
core/src/Streamly/Internal/Data/Fold/Type.hs+2−4
@@ -416,12 +416,10 @@ import Prelude hiding (concatMap, filter, foldr, map, take)
416416-- >>> import Streamly.Data.Fold (Fold)
417417-- >>> import Streamly.Internal.Data.Stream.Type (Stream)
418418-- >>> import qualified Data.Foldable as Foldable
419−-- >>> import qualified Streamly.Prelude as Stream
420419-- >>> import qualified Streamly.Data.Fold as Fold
421420-- >>> import qualified Streamly.Internal.Data.Fold as Fold
422421-- >>> import qualified Streamly.Internal.Data.Fold.Type as Fold
423−-- >>> import qualified Streamly.Internal.Data.Stream.Type as Stream
424−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream
422+-- >>> import qualified Streamly.Internal.Data.Stream as Stream
425423-- >>> import qualified Streamly.Internal.Data.Stream.StreamK as StreamK
426424-- >>> import Prelude hiding (concatMap, filter, map)
427425
@@ -1042,7 +1040,7 @@ data ConcatMapState m sa a c
10421040--
10431041-- /Time: O(n^2) where @n@ is the number of compositions./
10441042--
1045−-- See also: 'Streamly.Internal.Data.Stream.IsStream.foldIterateM', 'refold'
1043+-- See also: 'Streamly.Internal.Data.Stream.foldIterateM', 'refold'
10461044--
10471045-- @since 0.8.0
10481046--
core/src/Streamly/Internal/Data/Fold/Window.hs+1−1
@@ -73,7 +73,7 @@ import Prelude hiding (length, sum, minimum, maximum)
7373-- >>> import qualified Streamly.Data.Fold as Fold
7474-- >>> import qualified Streamly.Internal.Data.Fold.Window as FoldW
7575-- >>> import qualified Streamly.Internal.Data.Ring.Foreign as Ring
76−-- >>> import qualified Streamly.Prelude as Stream
76+-- >>> import qualified Streamly.Data.Stream as Stream
7777-- >>> import Prelude hiding (length, sum, minimum, maximum)
7878
7979-------------------------------------------------------------------------------
core/src/Streamly/Internal/Data/Parser.hs+4−4
@@ -266,8 +266,8 @@ import qualified Streamly.Internal.Data.Stream.Type as Stream
266266-- >>> import Control.Applicative ((<|>))
267267-- >>> import Data.Char (isSpace)
268268-- >>> import qualified Data.Maybe as Maybe
269−-- >>> import qualified Streamly.Prelude as Stream
270−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream (parse, parseMany)
269+-- >>> import qualified Streamly.Data.Stream as Stream
270+-- >>> import qualified Streamly.Internal.Data.Stream as Stream (parse, parseMany)
271271-- >>> import qualified Streamly.Internal.Data.Fold as Fold
272272-- >>> import qualified Streamly.Internal.Data.Parser as Parser
273273
@@ -945,7 +945,7 @@ wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSpc =
945945--
946946-- >>> :{
947947-- runGroupsBy eq =
948−-- Stream.toList
948+-- Stream.fold Fold.toList
949949-- . Stream.parseMany (Parser.groupBy eq Fold.toList)
950950-- . Stream.fromList
951951-- :}
@@ -979,7 +979,7 @@ groupBy eq = D.toParserK . D.groupBy eq
979979--
980980-- >>> :{
981981-- runGroupsByRolling eq =
982−-- Stream.toList
982+-- Stream.fold Fold.toList
983983-- . Stream.parseMany (Parser.groupByRolling eq Fold.toList)
984984-- . Stream.fromList
985985-- :}
core/src/Streamly/Internal/Data/Parser/ParserD.hs+2−2
@@ -226,8 +226,8 @@ import Streamly.Internal.Data.Parser.ParserD.Type
226226-- >>> :set -package streamly
227227-- >>> import Prelude hiding ()
228228-- >>> import qualified Data.Maybe as Maybe
229−-- >>> import qualified Streamly.Prelude as Stream
230−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream
229+-- >>> import qualified Streamly.Data.Stream as Stream
230+-- >>> import qualified Streamly.Internal.Data.Stream as Stream
231231-- >>> import qualified Streamly.Data.Fold as Fold
232232-- >>> import qualified Streamly.Internal.Data.Parser as Parser
233233
core/src/Streamly/Internal/Data/Parser/ParserD/Type.hs+2−2
@@ -229,8 +229,8 @@ import Prelude hiding (concatMap, filter)
229229-- >>> import Control.Applicative ((<|>))
230230-- >>> import Data.Bifunctor (second)
231231-- >>> import Prelude hiding (concatMap)
232−-- >>> import qualified Streamly.Prelude as Stream
233−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream (parse)
232+-- >>> import qualified Streamly.Data.Stream as Stream
233+-- >>> import qualified Streamly.Internal.Data.Stream as Stream (parse)
234234-- >>> import qualified Streamly.Internal.Data.Parser as Parser
235235-- >>> import qualified Streamly.Internal.Data.Parser.ParserD as ParserD
236236
core/src/Streamly/Internal/Data/Refold/Type.hs+2−2
@@ -54,7 +54,7 @@ import Prelude hiding (take, iterate)
5454-- >>> :set -package streamly
5555-- >>> import qualified Streamly.Internal.Data.Refold.Type as Refold
5656-- >>> 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
5858
5959-- All folds in the Fold module should be implemented using Refolds.
6060--
@@ -145,7 +145,7 @@ drainBy f = Refold step inject extract
145145
146146-- | Append the elements of an input stream to a provided starting value.
147147--
148−-- >>> stream = Stream.map Data.Monoid.Sum $ Stream.enumerateFromTo 1 10
148+-- >>> stream = fmap Data.Monoid.Sum $ Stream.enumerateFromTo 1 10
149149-- >>> Stream.fold (Fold.fromRefold Refold.sconcat 10) stream
150150-- Sum {getSum = 65}
151151--
core/src/Streamly/Internal/Data/Stream/Serial.hs+2−2
@@ -9,7 +9,7 @@
99--
1010-- To run examples in this module:
1111--
12−-- >>> import qualified Streamly.Prelude as Stream
12+-- >>> import qualified Streamly.Data.Stream as Stream
1313--
1414module Streamly.Internal.Data.Stream.Serial
1515 (
@@ -44,7 +44,7 @@ import qualified Streamly.Internal.Data.Stream as Stream
4444import Prelude hiding (map)
4545
4646-- $setup
47−-- >>> import qualified Streamly.Prelude as Stream
47+-- >>> import qualified Streamly.Data.Stream as Stream
4848
4949------------------------------------------------------------------------------
5050-- SerialT
core/src/Streamly/Internal/Data/Stream/StreamD/Exception.hs+11−11
@@ -173,7 +173,7 @@ gbracket bef aft onExc onGC ftry action =
173173 Skip s -> return $ Skip (GBracketIOException (Stream step1 s))
174174 Stop -> return Stop
175175
176−-- | See 'Streamly.Internal.Data.Stream.IsStream.before'.
176+-- | See 'Streamly.Internal.Data.Stream.before'.
177177--
178178{-# INLINE_NORMAL before #-}
179179before :: Monad m => m b -> Stream m a -> Stream m a
@@ -191,7 +191,7 @@ before action (Stream step state) = Stream step' Nothing
191191 Skip s -> return $ Skip (Just s)
192192 Stop -> return Stop
193193
194−-- | See 'Streamly.Internal.Data.Stream.IsStream.after_'.
194+-- | See 'Streamly.Internal.Data.Stream.after_'.
195195--
196196{-# INLINE_NORMAL after_ #-}
197197after_ :: Monad m => m b -> Stream m a -> Stream m a
@@ -207,7 +207,7 @@ after_ action (Stream step state) = Stream step' state
207207 Skip s -> return $ Skip s
208208 Stop -> action >> return Stop
209209
210−-- | See 'Streamly.Internal.Data.Stream.IsStream.after'.
210+-- | See 'Streamly.Internal.Data.Stream.after'.
211211--
212212{-# INLINE_NORMAL after #-}
213213after :: MonadRunInIO m
@@ -232,7 +232,7 @@ after action (Stream step state) = Stream step' Nothing
232232-- XXX For high performance error checks in busy streams we may need another
233233-- Error constructor in step.
234234--
235−-- | See 'Streamly.Internal.Data.Stream.IsStream.onException'.
235+-- | See 'Streamly.Internal.Data.Stream.onException'.
236236--
237237{-# INLINE_NORMAL onException #-}
238238onException :: MonadCatch m => m b -> Stream m a -> Stream m a
@@ -258,7 +258,7 @@ _onException action (Stream step state) = Stream step' state
258258 Skip s -> return $ Skip s
259259 Stop -> return Stop
260260
261−-- | See 'Streamly.Internal.Data.Stream.IsStream.bracket_'.
261+-- | See 'Streamly.Internal.Data.Stream.bracket_'.
262262--
263263{-# INLINE_NORMAL bracket_ #-}
264264bracket_ :: MonadCatch m
@@ -270,7 +270,7 @@ bracket_ bef aft =
270270 (\a (e :: SomeException) _ -> nilM (aft a >> MC.throwM e))
271271 (inline MC.try)
272272
273−-- | See 'Streamly.Internal.Data.Stream.IsStream.bracket'.
273+-- | See 'Streamly.Internal.Data.Stream.bracket'.
274274--
275275{-# INLINE_NORMAL bracket' #-}
276276bracket' :: (MonadAsync m, MonadCatch m) =>
@@ -314,13 +314,13 @@ _bracket bef aft bet = Stream step' BracketInit
314314 Skip s -> return $ Skip (BracketRun (Stream step s) v)
315315 Stop -> aft v >> return Stop
316316
317−-- | See 'Streamly.Internal.Data.Stream.IsStream.finally_'.
317+-- | See 'Streamly.Internal.Data.Stream.finally_'.
318318--
319319{-# INLINE finally_ #-}
320320finally_ :: MonadCatch m => m b -> Stream m a -> Stream m a
321321finally_ action xs = bracket_ (return ()) (const action) (const xs)
322322
323−-- | See 'Streamly.Internal.Data.Stream.IsStream.finally'.
323+-- | See 'Streamly.Internal.Data.Stream.finally'.
324324--
325325-- finally action xs = after action $ onException action xs
326326--
@@ -329,7 +329,7 @@ finally :: (MonadAsync m, MonadCatch m) => m b -> Stream m a -> Stream m a
329329finally action xs = bracket' (return ()) act act act (const xs)
330330 where act _ = action
331331
332−-- | See 'Streamly.Internal.Data.Stream.IsStream.ghandle'.
332+-- | See 'Streamly.Internal.Data.Stream.ghandle'.
333333--
334334{-# INLINE_NORMAL ghandle #-}
335335ghandle :: (MonadCatch m, Exception e)
@@ -337,7 +337,7 @@ ghandle :: (MonadCatch m, Exception e)
337337ghandle f stream =
338338 gbracket_ (return ()) return (const f) (inline MC.try) (const stream)
339339
340−-- | See 'Streamly.Internal.Data.Stream.IsStream.handle'.
340+-- | See 'Streamly.Internal.Data.Stream.handle'.
341341--
342342{-# INLINE_NORMAL handle #-}
343343handle :: (MonadCatch m, Exception e)
@@ -375,7 +375,7 @@ data RetryState emap s1 s2
375375 = RetryWithMap emap s1
376376 | RetryDefault s2
377377
378−-- | See 'Streamly.Internal.Data.Stream.IsStream.retry'
378+-- | See 'Streamly.Internal.Data.Stream.retry'
379379--
380380{-# INLINE_NORMAL retry #-}
381381retry
core/src/Streamly/Internal/Data/Stream/StreamD/Nesting.hs+4−1
@@ -555,7 +555,10 @@ data ConcatUnfoldInterleaveState o i =
555555-- of pairing up the streams we just need to go yielding one element from each
556556-- stream and storing the remaining streams and then keep doing rounds through
557557-- 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+--
559562{-# INLINE_NORMAL unfoldManyInterleave #-}
560563unfoldManyInterleave :: Monad m => Unfold m a b -> Stream m a -> Stream m b
561564unfoldManyInterleave (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
10441044 (\c n -> foldrSShared (\x b -> foldrSShared c b (unShare $ f x)) n xs)
10451045-}
10461046
1047−-- | See 'Streamly.Internal.Data.Stream.IsStream.concatPairsWith' for
1047+-- | See 'Streamly.Internal.Data.Stream.concatPairsWith' for
10481048-- documentation.
10491049--
10501050{-# INLINE concatPairsWith #-}
core/src/Streamly/Internal/Data/Stream/Top.hs+8−8
@@ -74,8 +74,8 @@ import Prelude hiding (filter, zipWith, concatMap, concat)
7474-- $setup
7575-- >>> :m
7676-- >>> import Prelude hiding (filter, zipWith, concatMap, concat)
77−-- >>> import qualified Streamly.Prelude as Stream
78−-- >>> import qualified Streamly.Internal.Data.Stream.IsStream as Stream
77+-- >>> import qualified Streamly.Internal.Data.Fold as Fold
78+-- >>> import qualified Streamly.Internal.Data.Stream as Stream
7979
8080------------------------------------------------------------------------------
8181-- Sampling
@@ -87,7 +87,7 @@ import Prelude hiding (filter, zipWith, concatMap, concat)
8787-- | @sampleFromthen offset stride@ samples the element at @offset@ index and
8888-- then every element at strides of @stride@.
8989--
90−-- >>> Stream.toList $ Stream.sampleFromThen 2 3 $ Stream.enumerateFromTo 0 10
90+-- >>> Stream.fold Fold.toList $ Stream.sampleFromThen 2 3 $ Stream.enumerateFromTo 0 10
9191-- [2,5,8]
9292--
9393-- /Pre-release/
@@ -489,15 +489,15 @@ mergeOuterJoin _eq _s1 _s2 = undefined
489489-- | 'intersectBy' is essentially a filtering operation that retains only those
490490-- elements in the first stream that are present in the second stream.
491491--
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])
493493-- [1,2,2]
494494--
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])
496496-- [2,1,1]
497497--
498498-- 'intersectBy' is similar to but not the same as 'joinInner':
499499--
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])
501501-- [1,1,2,2]
502502--
503503-- Space: O(n) where @n@ is the number of elements in the second stream.
@@ -537,7 +537,7 @@ intersectBySorted eq s1 =
537537-- present in the second stream. If an element occurs multiple times in the
538538-- second stream as many occurrences of it are deleted from the first stream.
539539--
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])
541541-- [2]
542542--
543543-- The following laws hold:
@@ -584,7 +584,7 @@ mergeDifferenceBy _eq _s1 _s2 = undefined
584584-- occurrences of elements from the second stream that are not already present
585585-- in the first stream.
586586--
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])
588588-- [1,2,2,4,3]
589589--
590590-- 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
118118
119119 -- * Unfolds
120120 -- One to one correspondence with
121− -- "Streamly.Internal.Data.Stream.IsStream.Generate"
121+ -- "Streamly.Internal.Data.Stream.Generate"
122122 -- ** Basic Constructors
123123 , mkUnfoldM
124124 , mkUnfoldrM
@@ -297,7 +297,7 @@ import Foreign.Ptr
297297-- $setup
298298-- >>> import qualified Streamly.Data.Fold as Fold
299299-- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
300−-- >>> import qualified Streamly.Prelude as Stream
300+-- >>> import qualified Streamly.Data.Stream as Stream
301301
302302
303303-- | 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
7373
7474-- $setup
7575-- >>> :m
76−-- >>> import qualified Streamly.Prelude as Stream
76+-- >>> import qualified Streamly.Data.Fold as Fold
77+-- >>> import qualified Streamly.Data.Stream as Stream
7778-- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
7879-- >>> import Streamly.Internal.Data.Unfold.Type
7980-- >>> import Data.Word
@@ -87,7 +88,7 @@ import Prelude
8788-- the value overflows it keeps enumerating in a cycle:
8889--
8990-- @
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)
9192-- [255,0,1,2,3,4,5,6,7,8]
9293--
9394-- @
@@ -124,7 +125,7 @@ enumerateFromStepNum = Unfold step inject
124125--
125126-- Example:
126127-- @
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)
128129-- [255,0,1,2,3,4,5,6,7,8]
129130--
130131-- @
@@ -151,7 +152,7 @@ enumerateFromThenNum =
151152--
152153-- @
153154-- >>> 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)
155156-- [0.9,1.9,2.9,3.9,4.9,5.9]
156157--
157158-- @
@@ -161,7 +162,7 @@ enumerateFromThenNum =
161162--
162163-- @
163164-- >>> 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)
165166-- [0.9,1.9,2.9,3.8999999999999995,4.8999999999999995,5.8999999999999995]
166167--
167168-- @
@@ -283,7 +284,7 @@ enumerateFromThenFractional = enumerateFromThenNum
283284-- specified upper limit rounded to the nearest integral value:
284285--
285286-- @
286−-- >>> Stream.toList $ Stream.unfold Unfold.enumerateFromToFractional (0.1, 6.3)
287+-- >>> Stream.fold Fold.toList $ Stream.unfold Unfold.enumerateFromToFractional (0.1, 6.3)
287288-- [0.1,1.1,2.1,3.1,4.1,5.1,6.1]
288289--
289290-- @
@@ -388,11 +389,11 @@ class Enum a => Enumerable a where
388389 -- @from@, enumerating up to 'maxBound' when the type is 'Bounded' or
389390 -- generating an infinite stream when the type is not 'Bounded'.
390391 --
391− -- >>> import qualified Streamly.Prelude as Stream
392+ -- >>> import qualified Streamly.Data.Stream as Stream
392393 -- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
393394 --
394395 -- @
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)
396397 -- [0,1,2,3]
397398 --
398399 -- @
@@ -401,7 +402,7 @@ class Enum a => Enumerable a where
401402 -- overflow or underflow checks are performed.
402403 --
403404 -- @
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
405406 -- [1.1,2.1,3.1,4.1]
406407 --
407408 -- @
@@ -414,11 +415,11 @@ class Enum a => Enumerable a where
414415 -- @from@, enumerating the type up to the value @to@. If @to@ is smaller than
415416 -- @from@ then an empty stream is returned.
416417 --
417− -- >>> import qualified Streamly.Prelude as Stream
418+ -- >>> import qualified Streamly.Data.Stream as Stream
418419 -- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
419420 --
420421 -- @
421− -- >>> Stream.toList $ Stream.unfold Unfold.enumerateFromTo (0, 4)
422+ -- >>> Stream.fold Fold.toList $ Stream.unfold Unfold.enumerateFromTo (0, 4)
422423 -- [0,1,2,3,4]
423424 --
424425 -- @
@@ -427,10 +428,10 @@ class Enum a => Enumerable a where
427428 -- value after rounding to the nearest integral value.
428429 --
429430 -- @
430− -- >>> Stream.toList $ Stream.unfold Unfold.enumerateFromTo (1.1, 4)
431+ -- >>> Stream.fold Fold.toList $ Stream.unfold Unfold.enumerateFromTo (1.1, 4)
431432 -- [1.1,2.1,3.1,4.1]
432433 --
433− -- >>> Stream.toList $ Stream.unfold Unfold.enumerateFromTo (1.1, 4.6)
434+ -- >>> Stream.fold Fold.toList $ Stream.unfold Unfold.enumerateFromTo (1.1, 4.6)
434435 -- [1.1,2.1,3.1,4.1,5.1]
435436 --
436437 -- @
@@ -444,14 +445,14 @@ class Enum a => Enumerable a where
444445 -- after @from@. For 'Bounded' types the stream ends when 'maxBound' is
445446 -- reached, for unbounded types it keeps enumerating infinitely.
446447 --
447− -- >>> import qualified Streamly.Prelude as Stream
448+ -- >>> import qualified Streamly.Data.Stream as Stream
448449 -- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
449450 --
450451 -- @
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)
452453 -- [0,2,4,6]
453454 --
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))
455456 -- [0,-2,-4,-6]
456457 --
457458 -- @
@@ -464,14 +465,14 @@ class Enum a => Enumerable a where
464465 -- @to@. Enumeration can occur downwards or upwards depending on whether @then@
465466 -- comes before or after @from@.
466467 --
467− -- >>> import qualified Streamly.Prelude as Stream
468+ -- >>> import qualified Streamly.Data.Stream as Stream
468469 -- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
469470 --
470471 -- @
471− -- >>> Stream.toList $ Stream.unfold Unfold.enumerateFromThenTo (0, 2, 6)
472+ -- >>> Stream.fold Fold.toList $ Stream.unfold Unfold.enumerateFromThenTo (0, 2, 6)
472473 -- [0,2,4,6]
473474 --
474− -- >>> Stream.toList $ Stream.unfold Unfold.enumerateFromThenTo (0, (-2), (-6))
475+ -- >>> Stream.fold Fold.toList $ Stream.unfold Unfold.enumerateFromThenTo (0, (-2), (-6))
475476 -- [0,-2,-4,-6]
476477 --
477478 -- @
core/src/Streamly/Internal/Data/Unfold/Type.hs+5−5
@@ -8,7 +8,7 @@
88--
99-- To run the examples in this module:
1010--
11−-- >>> import qualified Streamly.Prelude as Stream
11+-- >>> import qualified Streamly.Data.Stream as Stream
1212-- >>> import qualified Streamly.Data.Fold as Fold
1313-- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
1414
@@ -85,7 +85,7 @@ import Streamly.Internal.Data.Stream.StreamD.Step (Step(..))
8585import Prelude hiding (map, mapM, concatMap, zipWith, takeWhile)
8686
8787-- $setup
88−-- >>> import qualified Streamly.Prelude as Stream
88+-- >>> import qualified Streamly.Data.Stream as Stream
8989-- >>> import qualified Streamly.Data.Fold as Fold
9090-- >>> import qualified Streamly.Internal.Data.Unfold as Unfold
9191
@@ -549,7 +549,7 @@ apply u1 u2 = fmap (\(a, b) -> a b) (cross u1 u2)
549549--
550550-- >>> rlist = Unfold.lmap fst Unfold.fromList
551551-- >>> 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])
553553-- [(1,3),(1,4),(2,3),(2,4)]
554554--
555555instance Monad m => Applicative (Unfold m a) where
@@ -635,7 +635,7 @@ bind = flip concatMap
635635-- y <- Unfold.enumerateFromToIntegral x
636636-- return (x, y)
637637-- :}
638−-- >>> Stream.toList $ Stream.unfold u 1
638+-- >>> Stream.fold Fold.toList $ Stream.unfold u 1
639639-- [(1,1),(2,1),(2,2),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3),(4,4)]
640640--
641641instance Monad m => Monad (Unfold m a) where
@@ -850,7 +850,7 @@ data ManyInterleaveState o i =
850850 | ManyInterleaveInnerL [i] [i]
851851 | ManyInterleaveInnerR [i] [i]
852852
853−-- | 'Streamly.Internal.Data.Stream.IsStream.unfoldManyInterleave' for
853+-- | 'Streamly.Internal.Data.Stream.unfoldManyInterleave' for
854854-- documentation and notes.
855855--
856856-- This is almost identical to unfoldManyInterleave in StreamD module.