on master help sign in
Cleanup exports in Data.Stream modules
f9a81d4Harendra Kumar
core/src/Streamly/Internal/Data/Stream/Eliminate.hs+3−23
@@ -13,32 +13,19 @@
13--
13--
14module Streamly.Internal.Data.Stream.Eliminate
14module Streamly.Internal.Data.Stream.Eliminate
15 (
15 (
16− -- * Running a 'Fold'
16+ -- * Running a Parser
17− fold
18−
19− -- -- * Running a 'Parser'
20− , parse
17+ parse
21 , parseD
18 , parseD
22 , parseBreak
19 , parseBreak
23 , parseBreakD
20 , parseBreakD
24
21
25− -- * Stream Deconstruction
22+ -- * Deconstruction
26 , uncons
23 , uncons
27
24
28 -- * Right Folds
25 -- * Right Folds
29− , foldrM
30− , foldr
31− , foldrMx
32 , foldr1
26 , foldr1
33
27
34− -- * Left Folds
35− , foldlM'
36− , foldl'
37− , foldlMx'
38− , foldlx'
39−
40 -- * Specific Fold Functions
28 -- * Specific Fold Functions
41− , drain
42 , mapM_ -- Map and Fold
29 , mapM_ -- Map and Fold
43 , null
30 , null
44 , head
31 , head
@@ -61,16 +48,9 @@ module Streamly.Internal.Data.Stream.Eliminate
61 , the
48 , the
62
49
63 -- * To containers
50 -- * To containers
64− , toList
65 , toListRev
51 , toListRev
66
52
67 -- * Multi-Stream Folds
53 -- * Multi-Stream Folds
68− -- ** Comparisons
69− -- | These should probably be expressed using zipping operations.
70− , eqBy
71− , cmpBy
72−
73− -- ** Substreams
74 -- | These should probably be expressed using parsers.
54 -- | These should probably be expressed using parsers.
75 , isPrefixOf
55 , isPrefixOf
76 , isInfixOf
56 , isInfixOf
core/src/Streamly/Internal/Data/Stream/Exception.hs+9−6
@@ -9,17 +9,20 @@
9
9
10module Streamly.Internal.Data.Stream.Exception
10module Streamly.Internal.Data.Stream.Exception
11 (
11 (
12− gbracket_
12+ -- * Resources
13− , gbracket
14− , before
13+ before
15− , afterUnsafe
16 , afterIO
14 , afterIO
15+ , afterUnsafe
16+ , finallyIO
17+ , finallyUnsafe
18+ , gbracket_
19+ , gbracket
17 , bracketUnsafe
20 , bracketUnsafe
18 , bracketIO3
21 , bracketIO3
19 , bracketIO
22 , bracketIO
23+
24+ -- * Exceptions
20 , onException
25 , onException
21− , finallyUnsafe
22− , finallyIO
23 , ghandle
26 , ghandle
24 , handle
27 , handle
25 )
28 )
core/src/Streamly/Internal/Data/Stream/Generate.hs−12
@@ -16,20 +16,13 @@ module Streamly.Internal.Data.Stream.Generate
16 (
16 (
17 -- * Primitives
17 -- * Primitives
18 nil
18 nil
19− , nilM
20 , cons
19 , cons
21− , consM
22−
23− -- * From 'Unfold'
24− , unfold
25
20
26 -- * Unfolding
21 -- * Unfolding
27 , unfoldr
22 , unfoldr
28 , unfoldrM
23 , unfoldrM
29
24
30 -- * From Values
25 -- * From Values
31− , fromPure
32− , fromEffect
33 , repeat
26 , repeat
34 , repeatM
27 , repeatM
35 , replicate
28 , replicate
@@ -95,7 +88,6 @@ module Streamly.Internal.Data.Stream.Generate
95 -- * From Containers
88 -- * From Containers
96 -- | Transform an input structure into a stream.
89 -- | Transform an input structure into a stream.
97
90
98− , fromList
99 , fromListM
91 , fromListM
100 , fromFoldable
92 , fromFoldable
101 , fromFoldableM
93 , fromFoldableM
@@ -104,10 +96,6 @@ module Streamly.Internal.Data.Stream.Generate
104 , fromPtr
96 , fromPtr
105 , fromPtrN
97 , fromPtrN
106 , fromByteStr#
98 , fromByteStr#
107−
108− -- * Conversions
109− , fromStreamK
110− , toStreamK
111 )
99 )
112where
100where
113
101
core/src/Streamly/Internal/Data/Stream/Nesting.hs+8−18
@@ -55,11 +55,6 @@ module Streamly.Internal.Data.Stream.Nesting
55 -- yields an element. A special case of unfoldRoundRobin.
55 -- yields an element. A special case of unfoldRoundRobin.
56 , roundRobin -- interleaveFair?/ParallelFair
56 , roundRobin -- interleaveFair?/ParallelFair
57
57
58− -- *** Zipping
59− -- | Zip corresponding elements of two streams.
60− , zipWith
61− , zipWithM
62−
63 -- *** Merging
58 -- *** Merging
64 -- | Interleave elements from two streams based on a condition.
59 -- | Interleave elements from two streams based on a condition.
65 , mergeBy
60 , mergeBy
@@ -76,17 +71,10 @@ module Streamly.Internal.Data.Stream.Nesting
76 -- unfoldMany: Unfold m a b -> t m a -> t m b
71 -- unfoldMany: Unfold m a b -> t m a -> t m b
77 -- @
72 -- @
78
73
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−
85 -- *** ConcatUnfold
74 -- *** ConcatUnfold
86 -- | Generate streams by using an unfold on each element of an input
75 -- | Generate streams by using an unfold on each element of an input
87 -- stream, append the resulting streams and flatten. A special case of
76 -- stream, append the resulting streams and flatten. A special case of
88 -- gintercalate.
77 -- gintercalate.
89− , unfoldMany
90 , ConcatUnfoldInterleaveState (..)
78 , ConcatUnfoldInterleaveState (..)
91 , unfoldInterleave
79 , unfoldInterleave
92 , unfoldRoundRobin
80 , unfoldRoundRobin
@@ -118,11 +106,8 @@ module Streamly.Internal.Data.Stream.Nesting
118
106
119 -- ** Folding
107 -- ** Folding
120 -- | Apply folds on a stream.
108 -- | Apply folds on a stream.
121− , foldMany
122− , refoldMany
123 , foldSequence
109 , foldSequence
124 , foldIterateM
110 , foldIterateM
125− , refoldIterateM
126
111
127 -- ** Parsing
112 -- ** Parsing
128 -- | Parsing is opposite to flattening. 'parseMany' is dual to concatMap or
113 -- | Parsing is opposite to flattening. 'parseMany' is dual to concatMap or
@@ -139,7 +124,6 @@ module Streamly.Internal.Data.Stream.Nesting
139
124
140 -- ** Grouping
125 -- ** Grouping
141 -- | Group segments of a stream and fold. Special case of parsing.
126 -- | Group segments of a stream and fold. Special case of parsing.
142− , groupsOf
143 , groupsBy
127 , groupsBy
144 , groupsWhile
128 , groupsWhile
145 , groupsRollingBy
129 , groupsRollingBy
@@ -147,8 +131,8 @@ module Streamly.Internal.Data.Stream.Nesting
147 -- ** Splitting
131 -- ** Splitting
148 -- | A special case of parsing.
132 -- | A special case of parsing.
149 , wordsBy
133 , wordsBy
150− , splitOnSeq
134+ , splitOnSeq -- XXX splitOnSeg
151− , splitOnSuffixSeq
135+ , splitOnSuffixSeq -- XXX splitOnSegSuffix, splitOnTrailer
152
136
153 -- XXX Implement these as folds or parsers instead.
137 -- XXX Implement these as folds or parsers instead.
154 , splitOnSuffixSeqAny
138 , splitOnSuffixSeqAny
@@ -3046,6 +3030,8 @@ splitInnerBySuffix isEmpty splitter joiner (Stream step1 state1) =
3046--
3030--
3047-- Space: @O(1)@
3031-- Space: @O(1)@
3048--
3032--
3033+-- See also stripPrefix.
3034+--
3049-- /Unimplemented/
3035-- /Unimplemented/
3050{-# INLINE dropPrefix #-}
3036{-# INLINE dropPrefix #-}
3051dropPrefix ::
3037dropPrefix ::
@@ -3058,6 +3044,8 @@ dropPrefix = error "Not implemented yet!"
3058--
3044--
3059-- Space: @O(n)@ where n is the length of the infix.
3045-- Space: @O(n)@ where n is the length of the infix.
3060--
3046--
3047+-- See also stripInfix.
3048+--
3061-- /Unimplemented/
3049-- /Unimplemented/
3062{-# INLINE dropInfix #-}
3050{-# INLINE dropInfix #-}
3063dropInfix ::
3051dropInfix ::
@@ -3070,6 +3058,8 @@ dropInfix = error "Not implemented yet!"
3070--
3058--
3071-- Space: @O(n)@ where n is the length of the suffix.
3059-- Space: @O(n)@ where n is the length of the suffix.
3072--
3060--
3061+-- See also stripSuffix.
3062+--
3073-- /Unimplemented/
3063-- /Unimplemented/
3074{-# INLINE dropSuffix #-}
3064{-# INLINE dropSuffix #-}
3075dropSuffix ::
3065dropSuffix ::
core/src/Streamly/Internal/Data/Stream/Transform.hs+1−26
@@ -21,8 +21,6 @@ module Streamly.Internal.Data.Stream.Transform
21
21
22 -- * Mapping
22 -- * Mapping
23 -- | Stateless one-to-one maps.
23 -- | Stateless one-to-one maps.
24− , map
25− , mapM
26 , sequence
24 , sequence
27
25
28 -- * Mapping Effects
26 -- * Mapping Effects
@@ -75,7 +73,7 @@ module Streamly.Internal.Data.Stream.Transform
75 , scanMaybe
73 , scanMaybe
76 , filter
74 , filter
77 , filterM
75 , filterM
78− , deleteBy
76+ , deleteBy -- deleteOnceBy?
79 , uniqBy
77 , uniqBy
80 , uniq
78 , uniq
81 , prune
79 , prune
@@ -85,9 +83,6 @@ module Streamly.Internal.Data.Stream.Transform
85 -- | Produce a subset of the stream trimmed at ends.
83 -- | Produce a subset of the stream trimmed at ends.
86 , initNonEmpty
84 , initNonEmpty
87 , tailNonEmpty
85 , tailNonEmpty
88− , take
89− , takeWhile
90− , takeWhileM
91 , takeWhileLast
86 , takeWhileLast
92 , takeWhileAround
87 , takeWhileAround
93 , drop
88 , drop
@@ -134,7 +129,6 @@ module Streamly.Internal.Data.Stream.Transform
134 -- * Searching
129 -- * Searching
135 , findIndices
130 , findIndices
136 , elemIndices
131 , elemIndices
137− , slicesBy
138
132
139 -- * Rolling map
133 -- * Rolling map
140 -- | Map using the previous element.
134 -- | Map using the previous element.
@@ -1760,25 +1754,6 @@ findIndices p (Stream step state) = Stream step' (state, 0)
1760elemIndices :: (Monad m, Eq a) => a -> Stream m a -> Stream m Int
1754elemIndices :: (Monad m, Eq a) => a -> Stream m a -> Stream m Int
1761elemIndices a = findIndices (== a)
1755elemIndices a = findIndices (== a)
1762
1756
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−
1782------------------------------------------------------------------------------
1757------------------------------------------------------------------------------
1783-- Rolling map
1758-- Rolling map
1784------------------------------------------------------------------------------
1759------------------------------------------------------------------------------
core/src/Streamly/Internal/Data/Stream/Transformer.hs+2−1
@@ -11,10 +11,11 @@
11
11
12module Streamly.Internal.Data.Stream.Transformer
12module Streamly.Internal.Data.Stream.Transformer
13 (
13 (
14+ -- * Fold to Transformer Monad
14 foldlT
15 foldlT
15 , foldrT
16 , foldrT
16
17
17− -- * Transform Inner Monad
18+ -- * Inner Monad Operations
18 , liftInner
19 , liftInner
19 , runReaderT
20 , runReaderT
20 , usingReaderT
21 , usingReaderT
core/src/Streamly/Internal/Data/Stream/Type.hs+27−3
@@ -22,18 +22,18 @@
22
22
23module Streamly.Internal.Data.Stream.Type
23module Streamly.Internal.Data.Stream.Type
24 (
24 (
25− -- * The stream type
25+ -- * Type
26 Step (..)
26 Step (..)
27 -- XXX UnStream is exported to avoid a performance issue in some
27 -- XXX UnStream is exported to avoid a performance issue in some
28 -- combinators if we use the pattern synonym "Stream".
28 -- combinators if we use the pattern synonym "Stream".
29 , Stream (Stream, UnStream)
29 , Stream (Stream, UnStream)
30
30
31− -- * CrossStream type wrapper
31+ -- * CrossStream
32 , CrossStream
32 , CrossStream
33 , unCross
33 , unCross
34 , mkCross
34 , mkCross
35
35
36− -- * Conversion to StreamK
36+ -- * To StreamK
37 , fromStreamK
37 , fromStreamK
38 , toStreamK
38 , toStreamK
39
39
@@ -91,6 +91,7 @@ module Streamly.Internal.Data.Stream.Type
91
91
92 -- * Combining Two Streams
92 -- * Combining Two Streams
93 -- ** Zipping
93 -- ** Zipping
94+ -- | Zip corresponding elements of two streams.
94 , zipWithM
95 , zipWithM
95 , zipWith
96 , zipWith
96
97
@@ -106,6 +107,8 @@ module Streamly.Internal.Data.Stream.Type
106 , unfoldMany
107 , unfoldMany
107
108
108 -- * Concat
109 -- * Concat
110+ -- | Generate streams by mapping a stream generator on each element of an
111+ -- input stream, append the resulting streams and flatten.
109 , concatEffect
112 , concatEffect
110 , concatMap
113 , concatMap
111 , concatMapM
114 , concatMapM
@@ -139,6 +142,7 @@ module Streamly.Internal.Data.Stream.Type
139 , indexOnSuffix
142 , indexOnSuffix
140
143
141 -- * Multi-stream folds
144 -- * Multi-stream folds
145+ -- | These should probably be expressed using zipping operations.
142 , eqBy
146 , eqBy
143 , cmpBy
147 , cmpBy
144
148
@@ -2068,6 +2072,26 @@ indexOnSuffix predicate =
2068 (indexerBy (FL.takeEndBy_ predicate FL.length) 1)
2072 (indexerBy (FL.takeEndBy_ predicate FL.length) 1)
2069 (return (-1, 0))
2073 (return (-1, 0))
2070
2074
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+
2071{-# DEPRECATED sliceOnSuffix "Please use indexOnSuffix instead." #-}
2095{-# DEPRECATED sliceOnSuffix "Please use indexOnSuffix instead." #-}
2072sliceOnSuffix :: Monad m => (a -> Bool) -> Stream m a -> Stream m (Int, Int)
2096sliceOnSuffix :: Monad m => (a -> Bool) -> Stream m a -> Stream m (Int, Int)
2073sliceOnSuffix = indexOnSuffix
2097sliceOnSuffix = indexOnSuffix