@@ -39,6 +39,14 @@ module Streamly.Data.Stream
40 -- See also: "Streamly.Internal.Data.Stream.Generate" for
40 -- See also: "Streamly.Internal.Data.Stream.Generate" for
41 -- @Pre-release@ functions.
41 -- @Pre-release@ functions.
45+ -- >>> fromIndices f = fmap f $ Stream.enumerateFrom 0
46+ -- >>> fromIndicesM f = Stream.mapM f $ Stream.enumerateFrom 0
47+ -- >>> fromListM = Stream.sequence . Stream.fromList
48+ -- >>> fromFoldable = StreamK.toStream . StreamK.fromFoldable
49+ -- >>> fromFoldableM = Stream.sequence . fromFoldable
43 -- ** Primitives
51 -- ** Primitives
44 -- | Primitives to construct a stream from pure values or monadic actions.
52 -- | Primitives to construct a stream from pure values or monadic actions.
@@ -253,6 +261,14 @@ module Streamly.Data.Stream
255 -- ** Scanning By 'Fold'
263 -- ** Scanning By 'Fold'
266+ -- >>> scanl' f z = Stream.scan (Fold.foldl' f z)
267+ -- >>> scanlM' f z = Stream.scan (Fold.foldlM' f z)
268+ -- >>> postscanl' f z = Stream.postscan (Fold.foldl' f z)
269+ -- >>> postscanlM' f z = Stream.postscan (Fold.foldlM' f z)
270+ -- >>> scanl1' f = Stream.catMaybes . Stream.scan (Fold.foldl1' f)
271+ -- >>> scanl1M' f = Stream.catMaybes . Stream.scan (Fold.foldlM1' f)
257 , postscan
273 , postscan
258 -- XXX postscan1 can be implemented using Monoids or Refolds.
274 -- XXX postscan1 can be implemented using Monoids or Refolds.
@@ -298,6 +314,13 @@ module Streamly.Data.Stream
298 -- filtering folds (folds returning a 'Maybe' type) in
314 -- filtering folds (folds returning a 'Maybe' type) in
299 -- "Streamly.Internal.Data.Fold" can be used along with 'scanMaybe' to
315 -- "Streamly.Internal.Data.Fold" can be used along with 'scanMaybe' to
300 -- perform stateful filtering operations in general.
316 -- perform stateful filtering operations in general.
320+ -- >>> deleteBy cmp x = Stream.scanMaybe (Fold.deleteBy cmp x)
321+ -- >>> findIndices p = Stream.scanMaybe (Fold.findIndices p)
322+ -- >>> elemIndices a = findIndices (== a)
323+ -- >>> uniq = Stream.scanMaybe (Fold.uniqBy (==))
301 , scanMaybe
324 , scanMaybe
303 , takeWhile
326 , takeWhile
@@ -399,6 +422,14 @@ module Streamly.Data.Stream
399 , concatMapM
422 , concatMapM
401 -- * Repeated Fold
424 -- * Repeated Fold
427+ -- >>> splitWithSuffix p f = Stream.foldMany (Fold.takeEndBy p f)
428+ -- >>> splitOnSuffix p f = Stream.foldMany (Fold.takeEndBy_ p f)
429+ -- >>> groupsBy eq f = Stream.parseMany (Parser.groupBy eq f)
430+ -- >>> groupsByRolling eq f = Stream.parseMany (Parser.groupByRolling eq f)
431+ -- >>> wordsBy p f = Stream.parseMany (Parser.wordBy p f)
432+ -- >>> groupsOf n f = Stream.foldMany (Fold.take n f)
402 , foldMany -- XXX Rename to foldRepeat
433 , foldMany -- XXX Rename to foldRepeat
403 , parseMany
434 , parseMany
404 , Array.chunksOf
435 , Array.chunksOf
@@ -574,8 +605,3 @@ import Prelude
575-- 'Stream' and 'StreamK' types can be interconverted. See
606-- 'Stream' and 'StreamK' types can be interconverted. See
576-- "Streamly.Data.StreamK" module for conversion operations.
607-- "Streamly.Data.StreamK" module for conversion operations.
580−-- >>> fromListM = Stream.sequence . Stream.fromList
581−-- >>> fromIndices f = fmap f $ Stream.enumerateFrom 0