@@ -25,8 +25,11 @@ programmers to control concurrent behavior in a more robust way and
25reduce pitfalls.
25reduce pitfalls.
27The old code can be adapted to use the new modules with some
27The old code can be adapted to use the new modules with some
28−changes. More details about this is supplied in the following
28+changes. More details about this is supplied in the following sections.
29+Please open an issue if you cannot find a way to adapt the code to the new
29−sections. Assume the following imports in the code snippets below:
32+Assume the following imports in the code snippets below:
31```haskell docspec
34```haskell docspec
32>>> import qualified Streamly.Data.Stream as Stream
35>>> import qualified Streamly.Data.Stream as Stream
@@ -55,9 +58,9 @@ you will use most of the time. You can think of it as a replacement for
55the `SerialT` type. However, it does not provide an Applicative or Monad
58the `SerialT` type. However, it does not provide an Applicative or Monad
58−The `CrossStream` type in `Streamly.Internal.Data.Stream.StreamD` is a
61+The `CrossStream` type in `Streamly.Internal.Data.Stream` is a
59wrapper over `Stream` type supplying the Monad instance. However, see
62wrapper over `Stream` type supplying the Monad instance. However, see
60−the "Performance Notes" section in the `Streamly.Data.Stream` module for
63+the "Stream Fusion" section in the `Streamly.Data.Stream` module for
61limitations of the `Stream` type. The `StreamK` type and `CrossStreamK`
64limitations of the `Stream` type. The `StreamK` type and `CrossStreamK`
62(in Streamly.Internal.Data.Stream.StreamK) could be used to overcome the
65(in Streamly.Internal.Data.Stream.StreamK) could be used to overcome the
63limitations of `Stream` type.
66limitations of `Stream` type.
@@ -88,7 +91,6 @@ Explicit stream fold functions have been omitted from the new stream
88module. You can use the following equivalent definitions:
91module. You can use the following equivalent definitions:
90```haskell docspec
93```haskell docspec
91−>>> toList = Stream.fold Fold.toList
92>>> the = Stream.fold Fold.the
94>>> the = Stream.fold Fold.the
93>>> sum = Stream.fold Fold.sum
95>>> sum = Stream.fold Fold.sum
94>>> product = Stream.fold Fold.product
96>>> product = Stream.fold Fold.product
@@ -106,23 +108,21 @@ module. You can use the following equivalent definitions:
106>>> length = Stream.fold Fold.length
108>>> length = Stream.fold Fold.length
107>>> last = Stream.fold Fold.latest
109>>> last = Stream.fold Fold.latest
108>>> head = Stream.fold Fold.one
110>>> head = Stream.fold Fold.one
109−>>> foldr f a = Stream.fold (Fold.foldr' f a)
110>>> foldlM' f a = Stream.fold (Fold.foldlM' f a)
111>>> foldlM' f a = Stream.fold (Fold.foldlM' f a)
111>>> foldl1 f = Stream.fold (Fold.foldl1' f)
112>>> foldl1 f = Stream.fold (Fold.foldl1' f)
112>>> foldl' f a = Stream.fold (Fold.foldl' f a)
113>>> foldl' f a = Stream.fold (Fold.foldl' f a)
113>>> findIndex eq = Stream.fold (Fold.findIndex eq)
114>>> findIndex eq = Stream.fold (Fold.findIndex eq)
114>>> find eq = Stream.fold (Fold.find eq)
115>>> find eq = Stream.fold (Fold.find eq)
115>>> findM eq = Stream.fold (Fold.findM eq)
116>>> findM eq = Stream.fold (Fold.findM eq)
116−>>> drainWhile predicate = Stream.fold Fold.drain . Stream.takeWhile predicate
117+>>> drainWhile p = Stream.fold Fold.drain . Stream.takeWhile p
117>>> drainN i = Stream.fold Fold.drain . Stream.take i
118>>> drainN i = Stream.fold Fold.drain . Stream.take i
118>>> drain = Stream.fold Fold.drain
119>>> drain = Stream.fold Fold.drain
119−>>> any predicate = Stream.fold (Fold.any predicate)
120+>>> any p = Stream.fold (Fold.any p)
120>>> and = Stream.fold Fold.and
121>>> and = Stream.fold Fold.and
121−>>> all predicate = Stream.fold (Fold.all predicate)
122+>>> all p = Stream.fold (Fold.all p)
122>>> (!!) i = Stream.fold (Fold.index i)
123>>> (!!) i = Stream.fold (Fold.index i)
123>>> tail = Streamly.Internal.Data.Stream.StreamK.tail
124>>> tail = Streamly.Internal.Data.Stream.StreamK.tail
124>>> init = Streamly.Internal.Data.Stream.StreamK.init
125>>> init = Streamly.Internal.Data.Stream.StreamK.init
125−>>> foldrM = Streamly.Internal.Data.Stream.StreamD.foldrM
128Mapping functions:
128Mapping functions:
@@ -155,33 +155,32 @@ Filters:
155>>> elemIndices a = findIndices (== a)
155>>> elemIndices a = findIndices (== a)
158−Direct implementations of most of these folds, scans and filters are also
158+Custom implementations of most of these folds, scans and filters are also
159−available in the `Streamly.Internal.Data.Stream.StreamD` module. Those may in
159+available in the `Streamly.Internal.Data.Stream` module.
160−fact be better fusible in some situations.
162## Stream splitting and grouping functions
161## Stream splitting and grouping functions
164Stream splitting and grouping functions like `splitOn`, `wordsBy`, and
163Stream splitting and grouping functions like `splitOn`, `wordsBy`, and
165`groupsBy` have been omitted from the new stream module as these can
164`groupsBy` have been omitted from the new stream module as these can
166now be implemented using `foldMany` and an appropriate fold from the
165now be implemented using `foldMany` and an appropriate fold from the
167−`Streamly.Data.Fold` module or using `parseMany` and an appropriate
166+`Streamly.Data.Fold` module, or using `parseMany` and an appropriate
168parser from the `Streamly.Data.Parser` module.
167parser from the `Streamly.Data.Parser` module.
170```haskell docspec
169```haskell docspec
171>>> uniq = Stream.scanMaybe (Fold.uniqBy (==))
170>>> uniq = Stream.scanMaybe (Fold.uniqBy (==))
172−>>> splitWithSuffix predicate f = Stream.foldMany (Fold.takeEndBy predicate f)
171+>>> splitWithSuffix p f = Stream.foldMany (Fold.takeEndBy p f)
173−>>> splitOn = Streamly.Internal.Data.Stream.StreamD.splitOn
172+>>> splitOn = Streamly.Internal.Data.Stream.splitOn
174−>>> splitOnSuffix predicate f = Stream.foldMany (Fold.takeEndBy_ predicate f)
173+>>> splitOnSuffix p f = Stream.foldMany (Fold.takeEndBy_ p f)
175−>>> indexedR = Streamly.Internal.Data.Stream.StreamD.indexedR
174+>>> indexedR = Streamly.Internal.Data.Stream.indexedR
176>>> groupsBy eq fld = Stream.parseMany (Parser.groupBy eq fld)
175>>> groupsBy eq fld = Stream.parseMany (Parser.groupBy eq fld)
177>>> groups = groupsBy (==)
176>>> groups = groupsBy (==)
178−>>> groupsByRolling = Streamly.Internal.Data.Stream.StreamD.groupsRollingBy
177+>>> groupsByRolling = Streamly.Internal.Data.Stream.groupsRollingBy
179>>> wordsBy p f = Stream.parseMany (Parser.wordBy p f)
178>>> wordsBy p f = Stream.parseMany (Parser.wordBy p f)
180>>> chunksOf n f = Stream.foldMany (Fold.take n f)
179>>> chunksOf n f = Stream.foldMany (Fold.take n f)
183Direct implementation of these are also available in
182Direct implementation of these are also available in
184−`Streamly.Internal.Data.Stream.StreamD`.
183+`Streamly.Internal.Data.Stream`.
186## Concurrency
185## Concurrency