on master help sign in
Cleanup exports in Data.Stream modules

Remove redundant exports. Add headings, so that they do not get mixed up in haddock docs. Reorder in some cases.

commitf9a81d441e7752ad41346bf663572d51754f8cd4 authorHarendra Kumar <harendra@composewell.com> dateWed 24 Jan 2024, 13:31 (3 years ago) parentb95b3c1
7 files changed+50−89
core/src/Streamly/Internal/Data/Stream/Eliminate.hs+3−23 core/src/Streamly/Internal/Data/Stream/Exception.hs+9−6 core/src/Streamly/Internal/Data/Stream/Generate.hs−12 core/src/Streamly/Internal/Data/Stream/Nesting.hs+8−18 core/src/Streamly/Internal/Data/Stream/Transform.hs+1−26 core/src/Streamly/Internal/Data/Stream/Transformer.hs+2−1 core/src/Streamly/Internal/Data/Stream/Type.hs+27−3
core/src/Streamly/Internal/Data/Stream/Eliminate.hs+3−23
@@ -13,32 +13,19 @@
1313--
1414module Streamly.Internal.Data.Stream.Eliminate
1515 (
16− -- * Running a 'Fold'
17− fold
18−
19− -- -- * Running a 'Parser'
20− , parse
16+ -- * Running a Parser
17+ parse
2118 , parseD
2219 , parseBreak
2320 , parseBreakD
2421
25− -- * Stream Deconstruction
22+ -- * Deconstruction
2623 , uncons
2724
2825 -- * Right Folds
29− , foldrM
30− , foldr
31− , foldrMx
3226 , foldr1
3327
34− -- * Left Folds
35− , foldlM'
36− , foldl'
37− , foldlMx'
38− , foldlx'
39−
4028 -- * Specific Fold Functions
41− , drain
4229 , mapM_ -- Map and Fold
4330 , null
4431 , head
@@ -61,16 +48,9 @@ module Streamly.Internal.Data.Stream.Eliminate
6148 , the
6249
6350 -- * To containers
64− , toList
6551 , toListRev
6652
6753 -- * Multi-Stream Folds
68− -- ** Comparisons
69− -- | These should probably be expressed using zipping operations.
70− , eqBy
71− , cmpBy
72−
73− -- ** Substreams
7454 -- | These should probably be expressed using parsers.
7555 , isPrefixOf
7656 , isInfixOf
core/src/Streamly/Internal/Data/Stream/Exception.hs+9−6
@@ -9,17 +9,20 @@
99
1010module Streamly.Internal.Data.Stream.Exception
1111 (
12− gbracket_
13− , gbracket
14− , before
15− , afterUnsafe
12+ -- * Resources
13+ before
1614 , afterIO
15+ , afterUnsafe
16+ , finallyIO
17+ , finallyUnsafe
18+ , gbracket_
19+ , gbracket
1720 , bracketUnsafe
1821 , bracketIO3
1922 , bracketIO
23+
24+ -- * Exceptions
2025 , onException
21− , finallyUnsafe
22− , finallyIO
2326 , ghandle
2427 , handle
2528 )
core/src/Streamly/Internal/Data/Stream/Generate.hs−12
@@ -16,20 +16,13 @@ module Streamly.Internal.Data.Stream.Generate
1616 (
1717 -- * Primitives
1818 nil
19− , nilM
2019 , cons
21− , consM
22−
23− -- * From 'Unfold'
24− , unfold
2520
2621 -- * Unfolding
2722 , unfoldr
2823 , unfoldrM
2924
3025 -- * From Values
31− , fromPure
32− , fromEffect
3326 , repeat
3427 , repeatM
3528 , replicate
@@ -95,7 +88,6 @@ module Streamly.Internal.Data.Stream.Generate
9588 -- * From Containers
9689 -- | Transform an input structure into a stream.
9790
98− , fromList
9991 , fromListM
10092 , fromFoldable
10193 , fromFoldableM
@@ -104,10 +96,6 @@ module Streamly.Internal.Data.Stream.Generate
10496 , fromPtr
10597 , fromPtrN
10698 , fromByteStr#
107−
108− -- * Conversions
109− , fromStreamK
110− , toStreamK
11199 )
112100where
113101
core/src/Streamly/Internal/Data/Stream/Nesting.hs+8−18
@@ -55,11 +55,6 @@ module Streamly.Internal.Data.Stream.Nesting
5555 -- yields an element. A special case of unfoldRoundRobin.
5656 , roundRobin -- interleaveFair?/ParallelFair
5757
58− -- *** Zipping
59− -- | Zip corresponding elements of two streams.
60− , zipWith
61− , zipWithM
62−
6358 -- *** Merging
6459 -- | Interleave elements from two streams based on a condition.
6560 , mergeBy
@@ -76,17 +71,10 @@ module Streamly.Internal.Data.Stream.Nesting
7671 -- unfoldMany: Unfold m a b -> t m a -> t m b
7772 -- @
7873
79− -- *** ConcatMap
80− -- | Generate streams by mapping a stream generator on each element of an
81− -- input stream, append the resulting streams and flatten.
82− , concatMap
83− , concatMapM
84−
8574 -- *** ConcatUnfold
8675 -- | Generate streams by using an unfold on each element of an input
8776 -- stream, append the resulting streams and flatten. A special case of
8877 -- gintercalate.
89− , unfoldMany
9078 , ConcatUnfoldInterleaveState (..)
9179 , unfoldInterleave
9280 , unfoldRoundRobin
@@ -118,11 +106,8 @@ module Streamly.Internal.Data.Stream.Nesting
118106
119107 -- ** Folding
120108 -- | Apply folds on a stream.
121− , foldMany
122− , refoldMany
123109 , foldSequence
124110 , foldIterateM
125− , refoldIterateM
126111
127112 -- ** Parsing
128113 -- | Parsing is opposite to flattening. 'parseMany' is dual to concatMap or
@@ -139,7 +124,6 @@ module Streamly.Internal.Data.Stream.Nesting
139124
140125 -- ** Grouping
141126 -- | Group segments of a stream and fold. Special case of parsing.
142− , groupsOf
143127 , groupsBy
144128 , groupsWhile
145129 , groupsRollingBy
@@ -147,8 +131,8 @@ module Streamly.Internal.Data.Stream.Nesting
147131 -- ** Splitting
148132 -- | A special case of parsing.
149133 , wordsBy
150− , splitOnSeq
151− , splitOnSuffixSeq
134+ , splitOnSeq -- XXX splitOnSeg
135+ , splitOnSuffixSeq -- XXX splitOnSegSuffix, splitOnTrailer
152136
153137 -- XXX Implement these as folds or parsers instead.
154138 , splitOnSuffixSeqAny
@@ -3046,6 +3030,8 @@ splitInnerBySuffix isEmpty splitter joiner (Stream step1 state1) =
30463030--
30473031-- Space: @O(1)@
30483032--
3033+-- See also stripPrefix.
3034+--
30493035-- /Unimplemented/
30503036{-# INLINE dropPrefix #-}
30513037dropPrefix ::
@@ -3058,6 +3044,8 @@ dropPrefix = error "Not implemented yet!"
30583044--
30593045-- Space: @O(n)@ where n is the length of the infix.
30603046--
3047+-- See also stripInfix.
3048+--
30613049-- /Unimplemented/
30623050{-# INLINE dropInfix #-}
30633051dropInfix ::
@@ -3070,6 +3058,8 @@ dropInfix = error "Not implemented yet!"
30703058--
30713059-- Space: @O(n)@ where n is the length of the suffix.
30723060--
3061+-- See also stripSuffix.
3062+--
30733063-- /Unimplemented/
30743064{-# INLINE dropSuffix #-}
30753065dropSuffix ::
core/src/Streamly/Internal/Data/Stream/Transform.hs+1−26
@@ -21,8 +21,6 @@ module Streamly.Internal.Data.Stream.Transform
2121
2222 -- * Mapping
2323 -- | Stateless one-to-one maps.
24− , map
25− , mapM
2624 , sequence
2725
2826 -- * Mapping Effects
@@ -75,7 +73,7 @@ module Streamly.Internal.Data.Stream.Transform
7573 , scanMaybe
7674 , filter
7775 , filterM
78− , deleteBy
76+ , deleteBy -- deleteOnceBy?
7977 , uniqBy
8078 , uniq
8179 , prune
@@ -85,9 +83,6 @@ module Streamly.Internal.Data.Stream.Transform
8583 -- | Produce a subset of the stream trimmed at ends.
8684 , initNonEmpty
8785 , tailNonEmpty
88− , take
89− , takeWhile
90− , takeWhileM
9186 , takeWhileLast
9287 , takeWhileAround
9388 , drop
@@ -134,7 +129,6 @@ module Streamly.Internal.Data.Stream.Transform
134129 -- * Searching
135130 , findIndices
136131 , elemIndices
137− , slicesBy
138132
139133 -- * Rolling map
140134 -- | Map using the previous element.
@@ -1760,25 +1754,6 @@ findIndices p (Stream step state) = Stream step' (state, 0)
17601754elemIndices :: (Monad m, Eq a) => a -> Stream m a -> Stream m Int
17611755elemIndices a = findIndices (== a)
17621756
1763−{-# INLINE_NORMAL slicesBy #-}
1764−slicesBy :: Monad m => (a -> Bool) -> Stream m a -> Stream m (Int, Int)
1765−slicesBy p (Stream step1 state1) = Stream step (Just (state1, 0, 0))
1766−
1767− where
1768−
1769− {-# INLINE_LATE step #-}
1770− step gst (Just (st, i, len)) = i `seq` len `seq` do
1771− r <- step1 (adaptState gst) st
1772− return
1773− $ case r of
1774− Yield x s ->
1775− if p x
1776− then Yield (i, len + 1) (Just (s, i + len + 1, 0))
1777− else Skip (Just (s, i, len + 1))
1778− Skip s -> Skip (Just (s, i, len))
1779− Stop -> if len == 0 then Stop else Yield (i, len) Nothing
1780− step _ Nothing = return Stop
1781−
17821757------------------------------------------------------------------------------
17831758-- Rolling map
17841759------------------------------------------------------------------------------
core/src/Streamly/Internal/Data/Stream/Transformer.hs+2−1
@@ -11,10 +11,11 @@
1111
1212module Streamly.Internal.Data.Stream.Transformer
1313 (
14+ -- * Fold to Transformer Monad
1415 foldlT
1516 , foldrT
1617
17− -- * Transform Inner Monad
18+ -- * Inner Monad Operations
1819 , liftInner
1920 , runReaderT
2021 , usingReaderT
core/src/Streamly/Internal/Data/Stream/Type.hs+27−3
@@ -22,18 +22,18 @@
2222
2323module Streamly.Internal.Data.Stream.Type
2424 (
25− -- * The stream type
25+ -- * Type
2626 Step (..)
2727 -- XXX UnStream is exported to avoid a performance issue in some
2828 -- combinators if we use the pattern synonym "Stream".
2929 , Stream (Stream, UnStream)
3030
31− -- * CrossStream type wrapper
31+ -- * CrossStream
3232 , CrossStream
3333 , unCross
3434 , mkCross
3535
36− -- * Conversion to StreamK
36+ -- * To StreamK
3737 , fromStreamK
3838 , toStreamK
3939
@@ -91,6 +91,7 @@ module Streamly.Internal.Data.Stream.Type
9191
9292 -- * Combining Two Streams
9393 -- ** Zipping
94+ -- | Zip corresponding elements of two streams.
9495 , zipWithM
9596 , zipWith
9697
@@ -106,6 +107,8 @@ module Streamly.Internal.Data.Stream.Type
106107 , unfoldMany
107108
108109 -- * Concat
110+ -- | Generate streams by mapping a stream generator on each element of an
111+ -- input stream, append the resulting streams and flatten.
109112 , concatEffect
110113 , concatMap
111114 , concatMapM
@@ -139,6 +142,7 @@ module Streamly.Internal.Data.Stream.Type
139142 , indexOnSuffix
140143
141144 -- * Multi-stream folds
145+ -- | These should probably be expressed using zipping operations.
142146 , eqBy
143147 , cmpBy
144148
@@ -2068,6 +2072,26 @@ indexOnSuffix predicate =
20682072 (indexerBy (FL.takeEndBy_ predicate FL.length) 1)
20692073 (return (-1, 0))
20702074
2075+-- Alternate implementation
2076+{-# INLINE_NORMAL _indexOnSuffix #-}
2077+_indexOnSuffix :: Monad m => (a -> Bool) -> Stream m a -> Stream m (Int, Int)
2078+_indexOnSuffix p (Stream step1 state1) = Stream step (Just (state1, 0, 0))
2079+
2080+ where
2081+
2082+ {-# INLINE_LATE step #-}
2083+ step gst (Just (st, i, len)) = i `seq` len `seq` do
2084+ r <- step1 (adaptState gst) st
2085+ return
2086+ $ case r of
2087+ Yield x s ->
2088+ if p x
2089+ then Yield (i, len + 1) (Just (s, i + len + 1, 0))
2090+ else Skip (Just (s, i, len + 1))
2091+ Skip s -> Skip (Just (s, i, len))
2092+ Stop -> if len == 0 then Stop else Yield (i, len) Nothing
2093+ step _ Nothing = return Stop
2094+
20712095{-# DEPRECATED sliceOnSuffix "Please use indexOnSuffix instead." #-}
20722096sliceOnSuffix :: Monad m => (a -> Bool) -> Stream m a -> Stream m (Int, Int)
20732097sliceOnSuffix = indexOnSuffix