on master help sign in
Move Streamly.Fold module
042b677Harendra Kumar
benchmark/Linear.hs+1−1
@@ -19,7 +19,7 @@ import qualified GHC.Exts as GHC
19import qualified Streamly.Benchmark.Prelude as Ops
19import qualified Streamly.Benchmark.Prelude as Ops
20
20
21import Streamly
21import Streamly
22−import qualified Streamly.Fold as FL
22+import qualified Streamly.Data.Fold as FL
23import qualified Streamly.Internal as Internal
23import qualified Streamly.Internal as Internal
24import qualified Streamly.Internal.Prelude as IP
24import qualified Streamly.Internal.Prelude as IP
25--import qualified Streamly.Pipe as Pipe
25--import qualified Streamly.Pipe as Pipe
benchmark/NanoBenchmarks.hs+1−1
@@ -11,7 +11,7 @@ import Streamly.SVar (MonadAsync)
11
11
12import qualified Streamly.Memory.Array as A
12import qualified Streamly.Memory.Array as A
13import qualified Streamly.FileSystem.Handle as FH
13import qualified Streamly.FileSystem.Handle as FH
14−import qualified Streamly.Fold as FL
14+import qualified Streamly.Data.Fold as FL
15import qualified Streamly.Internal.Prelude as Internal
15import qualified Streamly.Internal.Prelude as Internal
16import qualified Streamly.Prelude as S
16import qualified Streamly.Prelude as S
17import qualified Streamly.Streams.StreamK as K
17import qualified Streamly.Streams.StreamK as K
examples/HandleIO.hs+1−1
@@ -1,5 +1,5 @@
1import qualified Streamly.Prelude as S
1import qualified Streamly.Prelude as S
2−import qualified Streamly.Fold as FL
2+import qualified Streamly.Data.Fold as FL
3import qualified Streamly.Memory.Array as A
3import qualified Streamly.Memory.Array as A
4import qualified Streamly.FileSystem.Handle as FH
4import qualified Streamly.FileSystem.Handle as FH
5import qualified System.IO as FH
5import qualified System.IO as FH
examples/WordClassifier.hs+1−1
@@ -18,7 +18,7 @@ import qualified Data.Ord as Ord
18import Foreign.Storable (Storable(..))
18import Foreign.Storable (Storable(..))
19import qualified Streamly.Data.String as Streamly
19import qualified Streamly.Data.String as Streamly
20import qualified Streamly.FileSystem.Handle as FH
20import qualified Streamly.FileSystem.Handle as FH
21−import qualified Streamly.Fold as FL
21+import qualified Streamly.Data.Fold as FL
22import qualified Streamly.Internal as Streamly
22import qualified Streamly.Internal as Streamly
23import qualified Streamly.Memory.Array as A
23import qualified Streamly.Memory.Array as A
24import qualified Streamly.Prelude as Streamly
24import qualified Streamly.Prelude as Streamly
src/Streamly.hs+2−2
@@ -235,7 +235,7 @@ import qualified Streamly.Streams.StreamK as K
235-- In the following example, a 'Word8' stream is generated by using
235-- In the following example, a 'Word8' stream is generated by using
236-- 'Streamly.FileSystem.Handle.read' on a file handle, then the
236-- 'Streamly.FileSystem.Handle.read' on a file handle, then the
237-- 'Streamly.Prelude.splitBySuffix' transformation splits the stream on
237-- 'Streamly.Prelude.splitBySuffix' transformation splits the stream on
238−-- newlines (ascii value 10); it uses the 'Streamly.Fold.drain' fold to reduce
238+-- newlines (ascii value 10); it uses the 'Streamly.Data.Fold.drain' fold to reduce
239-- the resulting lines to unit values (@()@), 'Streamly.Prelude.length' fold
239-- the resulting lines to unit values (@()@), 'Streamly.Prelude.length' fold
240-- then counts the unit elements in the resulting stream which gives us the
240-- then counts the unit elements in the resulting stream which gives us the
241-- number of lines in the file:
241-- number of lines in the file:
@@ -267,7 +267,7 @@ import qualified Streamly.Streams.StreamK as K
267-- $folds
267-- $folds
268--
268--
269-- The way stream types in this module like 'SerialT' represent data sources,
269-- The way stream types in this module like 'SerialT' represent data sources,
270−-- the same way the 'Fold' type from "Streamly.Fold" represents data sinks or
270+-- the same way the 'Fold' type from "Streamly.Data.Fold" represents data sinks or
271-- reducers of streams. Reducers can be combined to consume a stream source in
271-- reducers of streams. Reducers can be combined to consume a stream source in
272-- many ways. The simplest is to reduce a stream source using a fold e.g.:
272-- many ways. The simplest is to reduce a stream source using a fold e.g.:
273--
273--
src/Streamly/Benchmark/FileIO/Stream.hs+2−2
@@ -59,8 +59,8 @@ import qualified Streamly.FileSystem.Handle as FH
59import qualified Streamly.FileSystem.Handle.Internal as FH
59import qualified Streamly.FileSystem.Handle.Internal as FH
60import qualified Streamly.Memory.Array as A
60import qualified Streamly.Memory.Array as A
61import qualified Streamly.Memory.Array.Types as AT
61import qualified Streamly.Memory.Array.Types as AT
62−import qualified Streamly.Internal.Prelude as S
62+import qualified Streamly.Prelude as S
63−import qualified Streamly.Fold as FL
63+import qualified Streamly.Data.Fold as FL
64import qualified Streamly.Data.String as SS
64import qualified Streamly.Data.String as SS
65import qualified Streamly.Internal as Internal
65import qualified Streamly.Internal as Internal
66import qualified Streamly.Internal.Prelude as IP
66import qualified Streamly.Internal.Prelude as IP
src/Streamly/Data/Fold.hsnew file+247
@@ -0,0 +1,247 @@
1+-- |
2+-- Module : Streamly.Data.Fold
3+-- Copyright : (c) 2019 Composewell Technologies
4+-- License : BSD3
5+-- Maintainer : harendra@composewell.com
6+-- Stability : experimental
7+-- Portability : GHC
8+--
9+-- A left fold consumes a stream and reduces it to a single value. The fold
10+-- operations in "Streamly.Prelude" cannot be combined such that multiple of
11+-- them can run on the same stream. This module provides a 'Fold' type that
12+-- represents a left fold. Multiple such folds can be combined using
13+-- combinators; a stream can then be supplied to the combined fold and it would
14+-- distribute the input to constituent folds according to the composition.
15+-- For example, an applicative composition distributes the same input to
16+-- the constituent folds and then combines the fold outputs. Similarly, a
17+-- partitioning combinator can divide the input among constituent folds.
18+-- All the combinators in this module are of true streaming nature, stream
19+-- elements are not unnecessarily buffered in memory, guaranteeing a constant
20+-- memory consumption.
21+--
22+-- Consider this module as the consumer side dual of the "Streamly.Prelude"
23+-- module. "Streamly.Prelude" provides combinators that can combine stream
24+-- sources in interesting ways whereas this module provides combinators that
25+-- combine stream consumers in interesting ways. In other words,
26+-- "Streamly.Prelude" provides stream merging capabilities while
27+-- "Streamly.Internal.Data.Fold" provides stream splitting capabilities.
28+--
29+-- > import qualified Streamly.Internal.Data.Fold as FL
30+
31+-- Also see the "Streamly.Sink" module that provides specialized left folds
32+-- that discard the outputs.
33+--
34+-- IMPORTANT: keep the signatures consistent with the folds in Streamly.Prelude
35+
36+module Streamly.Data.Fold
37+ (
38+ -- * Fold Type
39+ -- |
40+ -- A 'Fold' can be run over a stream using the 'runFold' combinator in
41+ -- "Streamly.Prelude":
42+ --
43+ -- >>> S.runFold FL.sum (S.enumerateFromTo 1 100)
44+ -- 5050
45+
46+ Fold -- (..)
47+
48+ -- , tail
49+ -- , init
50+
51+ -- ** Full Folds
52+ , drain
53+ , drainBy
54+ , last
55+ , length
56+ , sum
57+ , product
58+ , maximumBy
59+ , maximum
60+ , minimumBy
61+ , minimum
62+ -- , the
63+ , mean
64+ , variance
65+ , stdDev
66+
67+ -- ** Full Folds (Monoidal)
68+ , mconcat
69+ , foldMap
70+ , foldMapM
71+
72+ -- ** Full Folds (To Containers)
73+ -- | Avoid using these folds in scalable or performance critical
74+ -- applications, they buffer all the input in GC memory which can be
75+ -- detrimental to performance if the input is large.
76+
77+ , toList
78+
79+ -- ** Partial Folds
80+ -- , drainN
81+ -- , drainWhile
82+ -- , lastN
83+ -- , (!!)
84+ -- , genericIndex
85+ , index
86+ , head
87+ -- , findM
88+ , find
89+ , lookup
90+ , findIndex
91+ , elemIndex
92+ , null
93+ , elem
94+ , notElem
95+ -- XXX these are slower than right folds even when full input is used
96+ , all
97+ , any
98+ , and
99+ , or
100+
101+ -- * Transformations
102+ -- | Unlike stream producer types (e.g. @SerialT m a@) which have only
103+ -- output side, folds have an input side as well as an output side. In the
104+ -- type @Fold m a b@, the input type is @a@ and the output type is @b@.
105+ -- Transformations can be applied either on the input side or on the output
106+ -- side. The 'Functor' instance of a fold maps on the output of the fold:
107+ --
108+ -- >>> S.runFold (fmap show FL.sum) (S.enumerateFromTo 1 100)
109+ -- "5050"
110+ --
111+ -- However, the input side or contravariant transformations are more
112+ -- interesting for folds. The following sections describe the input
113+ -- transformation operations on a fold. The names of the operations are
114+ -- consistent with their covariant counterparts in "Streamly.Prelude", the
115+ -- only difference is that they are prefixed with 'l' which stands for
116+ -- 'left' assuming left side is the input side, notice that in @Fold m a b@
117+ -- the type variable @a@ is on the left side.
118+
119+ -- ** Covariant Operations
120+ , sequence
121+ , mapM
122+
123+ -- ** Mapping
124+ --, transform
125+ -- , lmap
126+ --, lsequence
127+ -- , lmapM
128+
129+ -- -- ** Filtering
130+ -- , lfilter
131+ -- , lfilterM
132+ -- , ldeleteBy
133+ -- , luniq
134+
135+ {-
136+ -- ** Mapping Filters
137+ , lmapMaybe
138+ , lmapMaybeM
139+
140+ -- ** Scanning Filters
141+ , lfindIndices
142+ , lelemIndices
143+
144+ -- ** Insertion
145+ -- | Insertion adds more elements to the stream.
146+
147+ , linsertBy
148+ , lintersperseM
149+
150+ -- ** Reordering
151+ , lreverse
152+ -}
153+
154+ {-
155+ -- * Parsing
156+ -- ** Trimming
157+ , ltake
158+ -- , lrunFor -- time
159+ , ltakeWhile
160+ , ltakeWhileM
161+ , ldrop
162+ , ldropWhile
163+ , ldropWhileM
164+ -}
165+
166+ -- * Distributing
167+ -- |
168+ -- The 'Applicative' instance of a distributing 'Fold' distributes one copy
169+ -- of the stream to each fold and combines the results using a function.
170+ --
171+ -- @
172+ --
173+ -- |-------Fold m a b--------|
174+ -- ---stream m a---| |---m (b,c,...)
175+ -- |-------Fold m a c--------|
176+ -- | |
177+ -- ...
178+ -- @
179+ --
180+ -- To compute the average of numbers in a stream without going throught he
181+ -- stream twice:
182+ --
183+ -- >>> let avg = (/) <$> FL.sum <*> fmap fromIntegral FL.length
184+ -- >>> S.runFold avg (S.enumerateFromTo 1.0 100.0)
185+ -- 50.5
186+ --
187+ -- The 'Semigroup' and 'Monoid' instances of a distributing fold distribute
188+ -- the input to both the folds and combines the outputs using Monoid or
189+ -- Semigroup instances of the output types:
190+ --
191+ -- >>> import Data.Monoid (Sum)
192+ -- >>> S.runFold (FL.head <> FL.last) (fmap Sum $ S.enumerateFromTo 1.0 100.0)
193+ -- Just (Sum {getSum = 101.0})
194+ --
195+ -- The 'Num', 'Floating', and 'Fractional' instances work in the same way.
196+
197+ , tee
198+ , distribute
199+
200+ -- * Partitioning
201+ -- |
202+ -- Direct items in the input stream to different folds using a binary
203+ -- fold selector.
204+
205+ -- , partitionByM
206+ -- , partitionBy
207+ , partition
208+
209+ -- * Demultiplexing
210+ -- | Direct values in the input stream to different folds using an n-ary
211+ -- fold selector.
212+
213+ , demux
214+ -- , demuxWith
215+ , demux_
216+ -- , demuxWith_
217+
218+ -- * Classifying
219+ -- | In an input stream of key value pairs fold values for different keys
220+ -- in individual output buckets using the given fold.
221+
222+ , classify
223+ -- , classifyWith
224+
225+ -- * Unzipping
226+ , unzip
227+ -- These can be expressed using lmap/lmapM and unzip
228+ -- , unzipWith
229+ -- , unzipWithM
230+
231+ -- -- * Nested Folds
232+ -- , concatMap
233+ -- , chunksOf
234+ -- , duplicate -- experimental
235+ )
236+where
237+
238+import Prelude
239+ hiding (filter, drop, dropWhile, take, takeWhile, zipWith, foldr,
240+ foldl, map, mapM_, sequence, all, any, sum, product, elem,
241+ notElem, maximum, minimum, head, last, tail, length, null,
242+ reverse, iterate, init, and, or, lookup, foldr1, (!!),
243+ scanl, scanl1, replicate, concatMap, mconcat, foldMap, unzip,
244+ span, splitAt, break, mapM)
245+
246+import Streamly.Internal.Data.Fold
247+import Streamly.Internal.Data.Fold.Types
src/Streamly/Data/String.hs+1−1
@@ -89,7 +89,7 @@ import Data.Word (Word8)
89import GHC.Base (unsafeChr)
89import GHC.Base (unsafeChr)
90import Streamly (IsStream, MonadAsync)
90import Streamly (IsStream, MonadAsync)
91import Prelude hiding (String, lines, words, unlines, unwords)
91import Prelude hiding (String, lines, words, unlines, unwords)
92−import Streamly.Fold (Fold)
92+import Streamly.Data.Fold (Fold)
93import Streamly.Memory.Array (Array)
93import Streamly.Memory.Array (Array)
94import Streamly.Unfold (Unfold)
94import Streamly.Unfold (Unfold)
95
95
src/Streamly/FileSystem/FD.hs+1−1
@@ -146,7 +146,7 @@ import Streamly.Streams.StreamD (toStreamD)
146import Streamly.Streams.StreamD.Type (fromStreamD)
146import Streamly.Streams.StreamD.Type (fromStreamD)
147import qualified Streamly.FileSystem.FDIO as RawIO hiding (write)
147import qualified Streamly.FileSystem.FDIO as RawIO hiding (write)
148#endif
148#endif
149−-- import Streamly.Fold (Fold)
149+-- import Streamly.Data.Fold (Fold)
150-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
150-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
151
151
152import qualified Streamly.Memory.Array as A
152import qualified Streamly.Memory.Array as A
src/Streamly/FileSystem/File.hs+1−1
@@ -119,7 +119,7 @@ import Streamly.Memory.Array.Types (Array(..), defaultChunkSize)
119import Streamly.Streams.Serial (SerialT)
119import Streamly.Streams.Serial (SerialT)
120import Streamly.Streams.StreamK.Type (IsStream)
120import Streamly.Streams.StreamK.Type (IsStream)
121import Streamly.SVar (MonadAsync)
121import Streamly.SVar (MonadAsync)
122−-- import Streamly.Fold (Fold)
122+-- import Streamly.Data.Fold (Fold)
123-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
123-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
124
124
125import qualified Streamly.FileSystem.Handle as FH
125import qualified Streamly.FileSystem.Handle as FH
src/Streamly/FileSystem/Handle.hs+3−3
@@ -123,11 +123,11 @@ import Streamly.Memory.Array.Types (Array(..), writeNUnsafe)
123import Streamly.Streams.StreamK.Type (IsStream, mkStream)
123import Streamly.Streams.StreamK.Type (IsStream, mkStream)
124import Streamly.Memory.Array.Types
124import Streamly.Memory.Array.Types
125 (defaultChunkSize, shrinkToFit, lpackArraysChunksOf)
125 (defaultChunkSize, shrinkToFit, lpackArraysChunksOf)
126−import Streamly.Fold (Fold)
126+import Streamly.Data.Fold (Fold)
127-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
127-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
128
128
129−import qualified Streamly.Fold as FL
129+import qualified Streamly.Data.Fold as FL
130−import qualified Streamly.Fold.Types as FL
130+import qualified Streamly.Internal.Data.Fold.Types as FL
131import qualified Streamly.Memory.Array as A
131import qualified Streamly.Memory.Array as A
132import qualified Streamly.Internal.Memory.ArrayStream as AS
132import qualified Streamly.Internal.Memory.ArrayStream as AS
133import qualified Streamly.Streams.StreamD.Type as D
133import qualified Streamly.Streams.StreamD.Type as D
src/Streamly/Fold/Internal.hs+1−1
@@ -24,7 +24,7 @@ module Streamly.Fold.Internal
24 )
24 )
25where
25where
26
26
27−import Streamly.Fold.Types (Fold(..))
27+import Streamly.Internal.Data.Fold.Types (Fold(..))
28
28
29-- | Compute an 'Int' sized polynomial rolling hash
29-- | Compute an 'Int' sized polynomial rolling hash
30--
30--
src/Streamly/Internal.hs+2−2
@@ -21,7 +21,7 @@ module Streamly.Internal
21 -- * Diagnostics
21 -- * Diagnostics
22 inspectMode
22 inspectMode
23
23
24− -- * Streamly.Fold Experimental Exports
24+ -- * Streamly.Internal.Data.Fold Experimental Exports
25 , Fold (..)
25 , Fold (..)
26 , toListRevF
26 , toListRevF
27 , rollingHash
27 , rollingHash
@@ -56,4 +56,4 @@ import Streamly.Unfold.Types (Unfold(..))
56import Streamly.Unfold (fromList)
56import Streamly.Unfold (fromList)
57
57
58import Streamly.Fold.Internal
58import Streamly.Fold.Internal
59−import Streamly.Fold.Types
59+import Streamly.Internal.Data.Fold.Types
src/Streamly/Internal/Data/Fold.hs+3−25
@@ -7,42 +7,20 @@
7{-# LANGUAGE ScopedTypeVariables #-}
7{-# LANGUAGE ScopedTypeVariables #-}
8
8
9-- |
9-- |
10−-- Module : Streamly.Fold
10+-- Module : Streamly.Internal.Data.Fold
11-- Copyright : (c) 2019 Composewell Technologies
11-- Copyright : (c) 2019 Composewell Technologies
12-- (c) 2013 Gabriel Gonzalez
12-- (c) 2013 Gabriel Gonzalez
13-- License : BSD3
13-- License : BSD3
14-- Maintainer : harendra.kumar@gmail.com
14-- Maintainer : harendra.kumar@gmail.com
15-- Stability : experimental
15-- Stability : experimental
16-- Portability : GHC
16-- Portability : GHC
17−--
18−-- A left fold consumes a stream and reduces it to a single value. The fold
19−-- operations in "Streamly.Prelude" cannot be combined such that multiple of
20−-- them can run on the same stream. This module provides a 'Fold' type that
21−-- represents a left fold. Multiple such folds can be combined using
22−-- combinators; a stream can then be supplied to the combined fold and it would
23−-- distribute the input to constituent folds according to the composition.
24−-- For example, an applicative composition distributes the same input to
25−-- the constituent folds and then combines the fold outputs. Similarly, a
26−-- partitioning combinator can divide the input among constituent folds.
27−-- All the combinators in this module are of true streaming nature, stream
28−-- elements are not unnecessarily buffered in memory, guaranteeing a constant
29−-- memory consumption.
30−--
31−-- Consider this module as the consumer side dual of the "Streamly.Prelude"
32−-- module. "Streamly.Prelude" provides combinators that can combine stream
33−-- sources in interesting ways whereas this module provides combinators that
34−-- combine stream consumers in interesting ways. In other words,
35−-- "Streamly.Prelude" provides stream merging capabilities while
36−-- "Streamly.Fold" provides stream splitting capabilities.
37−--
38−-- > import qualified Streamly.Fold as FL
39
17
40-- Also see the "Streamly.Sink" module that provides specialized left folds
18-- Also see the "Streamly.Sink" module that provides specialized left folds
41-- that discard the outputs.
19-- that discard the outputs.
42--
20--
43-- IMPORTANT: keep the signatures consistent with the folds in Streamly.Prelude
21-- IMPORTANT: keep the signatures consistent with the folds in Streamly.Prelude
44
22
45−module Streamly.Fold
23+module Streamly.Internal.Data.Fold
46 (
24 (
47 -- * Fold Type
25 -- * Fold Type
48 -- |
26 -- |
@@ -258,7 +236,7 @@ import Prelude
258import qualified Data.Map.Strict as Map
236import qualified Data.Map.Strict as Map
259import qualified Prelude
237import qualified Prelude
260
238
261−import Streamly.Fold.Types (Fold(..), lmap)
239+import Streamly.Internal.Data.Fold.Types (Fold(..), lmap)
262import Streamly.Pipe.Types (Pipe (..), PipeState(..))
240import Streamly.Pipe.Types (Pipe (..), PipeState(..))
263import Streamly.Strict
241import Streamly.Strict
264
242
src/Streamly/Internal/Data/Fold/Types.hs+2−2
@@ -3,7 +3,7 @@
3{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleContexts #-}
4
4
5-- |
5-- |
6−-- Module : Streamly.Fold.Types
6+-- Module : Streamly.Internal.Data.Fold.Types
7-- Copyright : (c) 2019 Composewell Technologies
7-- Copyright : (c) 2019 Composewell Technologies
8-- (c) 2013 Gabriel Gonzalez
8-- (c) 2013 Gabriel Gonzalez
9-- License : BSD3
9-- License : BSD3
@@ -11,7 +11,7 @@
11-- Stability : experimental
11-- Stability : experimental
12-- Portability : GHC
12-- Portability : GHC
13
13
14−module Streamly.Fold.Types
14+module Streamly.Internal.Data.Fold.Types
15 ( Fold (..)
15 ( Fold (..)
16 , toListRevF -- experimental
16 , toListRevF -- experimental
17 , lmap
17 , lmap
src/Streamly/Internal/Prelude.hs+3−3
@@ -403,7 +403,7 @@ import qualified Prelude
403import qualified System.IO as IO
403import qualified System.IO as IO
404
404
405import Streamly.Enumeration (Enumerable(..), enumerate, enumerateTo)
405import Streamly.Enumeration (Enumerable(..), enumerate, enumerateTo)
406−import Streamly.Fold.Types (Fold (..))
406+import Streamly.Internal.Data.Fold.Types (Fold (..))
407import Streamly.Unfold.Types (Unfold)
407import Streamly.Unfold.Types (Unfold)
408import Streamly.Memory.Array.Types (Array, writeNUnsafe)
408import Streamly.Memory.Array.Types (Array, writeNUnsafe)
409-- import Streamly.Memory.Ring (Ring)
409-- import Streamly.Memory.Ring (Ring)
@@ -423,8 +423,8 @@ import Streamly.Time.Units
423import Streamly.Strict
423import Streamly.Strict
424
424
425import qualified Streamly.Memory.Array.Types as A
425import qualified Streamly.Memory.Array.Types as A
426−import qualified Streamly.Fold as FL
426+import qualified Streamly.Data.Fold as FL
427−import qualified Streamly.Fold.Types as FL
427+import qualified Streamly.Internal.Data.Fold.Types as FL
428import qualified Streamly.Streams.Prelude as P
428import qualified Streamly.Streams.Prelude as P
429import qualified Streamly.Streams.StreamK as K
429import qualified Streamly.Streams.StreamK as K
430import qualified Streamly.Streams.StreamD as D
430import qualified Streamly.Streams.StreamD as D
src/Streamly/Memory/Array.hs+1−1
@@ -146,7 +146,7 @@ import Prelude hiding (length, null, last, map, (!!), read, concat)
146import Streamly.Memory.Array.Types (Array(..), length)
146import Streamly.Memory.Array.Types (Array(..), length)
147import Streamly.Streams.Serial (SerialT)
147import Streamly.Streams.Serial (SerialT)
148import Streamly.Streams.StreamK.Type (IsStream)
148import Streamly.Streams.StreamK.Type (IsStream)
149−import Streamly.Fold.Types (Fold(..))
149+import Streamly.Internal.Data.Fold.Types (Fold(..))
150
150
151import qualified Streamly.Memory.Array.Types as A
151import qualified Streamly.Memory.Array.Types as A
152import qualified Streamly.Internal.Memory.ArrayStream as AS
152import qualified Streamly.Internal.Memory.ArrayStream as AS
src/Streamly/Memory/Array/Types.hs+1−1
@@ -110,7 +110,7 @@ import GHC.ForeignPtr (ForeignPtr(..), newForeignPtr_)
110import GHC.IO (IO(IO), unsafePerformIO)
110import GHC.IO (IO(IO), unsafePerformIO)
111import GHC.Ptr (Ptr(..))
111import GHC.Ptr (Ptr(..))
112
112
113−import Streamly.Fold.Types (Fold(..))
113+import Streamly.Internal.Data.Fold.Types (Fold(..))
114import Streamly.Unfold.Types (Unfold(..))
114import Streamly.Unfold.Types (Unfold(..))
115import Streamly.Strict (Tuple'(..))
115import Streamly.Strict (Tuple'(..))
116import Streamly.SVar (adaptState)
116import Streamly.SVar (adaptState)
src/Streamly/Network/Client.hs+2−2
@@ -66,13 +66,13 @@ import Prelude hiding (read)
66import qualified Network.Socket as Net
66import qualified Network.Socket as Net
67
67
68import Streamly (MonadAsync)
68import Streamly (MonadAsync)
69−import Streamly.Fold.Types (Fold(..))
69+import Streamly.Internal.Data.Fold.Types (Fold(..))
70import Streamly.Memory.Array.Types (Array(..), defaultChunkSize, writeNUnsafe)
70import Streamly.Memory.Array.Types (Array(..), defaultChunkSize, writeNUnsafe)
71-- import Streamly.Streams.Serial (SerialT)
71-- import Streamly.Streams.Serial (SerialT)
72import Streamly.Streams.StreamK.Type (IsStream)
72import Streamly.Streams.StreamK.Type (IsStream)
73
73
74−import qualified Streamly.Fold.Types as FL
75import qualified Streamly.Internal.Memory.ArrayStream as AS
74import qualified Streamly.Internal.Memory.ArrayStream as AS
75+import qualified Streamly.Internal.Data.Fold.Types as FL
76import qualified Streamly.Prelude as S
76import qualified Streamly.Prelude as S
77import qualified Streamly.Network.Socket as SK
77import qualified Streamly.Network.Socket as SK
78
78
src/Streamly/Network/Socket.hs+3−3
@@ -89,11 +89,11 @@ import qualified Network.Socket as Net
89import Streamly.Memory.Array.Types (Array(..))
89import Streamly.Memory.Array.Types (Array(..))
90import Streamly.Streams.Serial (SerialT)
90import Streamly.Streams.Serial (SerialT)
91import Streamly.Streams.StreamK.Type (IsStream, mkStream)
91import Streamly.Streams.StreamK.Type (IsStream, mkStream)
92−import Streamly.Fold (Fold)
92+import Streamly.Data.Fold (Fold)
93-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
93-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
94
94
95−import qualified Streamly.Fold as FL
95+import qualified Streamly.Data.Fold as FL
96−import qualified Streamly.Fold.Types as FL
96+import qualified Streamly.Internal.Data.Fold.Types as FL
97import qualified Streamly.Memory.Array as A
97import qualified Streamly.Memory.Array as A
98import qualified Streamly.Internal.Memory.ArrayStream as AS
98import qualified Streamly.Internal.Memory.ArrayStream as AS
99import qualified Streamly.Memory.Array.Types as A
99import qualified Streamly.Memory.Array.Types as A
src/Streamly/Pipe.hs+2−2
@@ -15,7 +15,7 @@
15-- Portability : GHC
15-- Portability : GHC
16--
16--
17-- There are three fundamental types in streamly. They are streams
17-- There are three fundamental types in streamly. They are streams
18−-- ("Streamly.Prelude"), pipes ("Streamly.Pipe") and folds ("Streamly.Fold").
18+-- ("Streamly.Prelude"), pipes ("Streamly.Pipe") and folds ("Streamly.Data.Fold").
19-- Streams are sources or producers of values, multiple sources can be merged
19-- Streams are sources or producers of values, multiple sources can be merged
20-- into a single source but a source cannot be split into multiple stream
20-- into a single source but a source cannot be split into multiple stream
21-- sources. Folds are sinks or consumers, a stream can be split and
21-- sources. Folds are sinks or consumers, a stream can be split and
@@ -251,7 +251,7 @@ import Prelude
251-- import qualified Prelude
251-- import qualified Prelude
252
252
253-- import Streamly (MonadAsync, parallel)
253-- import Streamly (MonadAsync, parallel)
254−-- import Streamly.Fold.Types (Fold(..))
254+-- import Streamly.Data.Fold.Types (Fold(..))
255import Streamly.Pipe.Types
255import Streamly.Pipe.Types
256 (Pipe(..), PipeState(..), Step(..), zipWith, tee, map, compose)
256 (Pipe(..), PipeState(..), Step(..), zipWith, tee, map, compose)
257-- import Streamly.Memory.Array.Types (Array)
257-- import Streamly.Memory.Array.Types (Array)
src/Streamly/Prelude.hs+1−1
@@ -884,7 +884,7 @@ import Streamly.Internal.Prelude
884
884
885-- $runningfolds
885-- $runningfolds
886--
886--
887−-- "Streamly.Fold" module defines composable left folds which can be combined
887+-- "Streamly.Data.Fold" module defines composable left folds which can be combined
888-- together in many interesting ways. Those folds can be run using 'runFold'.
888-- together in many interesting ways. Those folds can be run using 'runFold'.
889-- The following two ways of folding are equivalent in functionality and
889-- The following two ways of folding are equivalent in functionality and
890-- performance,
890-- performance,
src/Streamly/Sink.hs+1−1
@@ -66,7 +66,7 @@ import Prelude
66 reverse, iterate, init, and, or, lookup, foldr1, (!!),
66 reverse, iterate, init, and, or, lookup, foldr1, (!!),
67 scanl, scanl1, replicate, concatMap, mconcat, foldMap, unzip)
67 scanl, scanl1, replicate, concatMap, mconcat, foldMap, unzip)
68
68
69−import Streamly.Fold.Types (Fold(..))
69+import Streamly.Internal.Data.Fold.Types (Fold(..))
70import Streamly.Sink.Types (Sink(..))
70import Streamly.Sink.Types (Sink(..))
71
71
72import qualified Data.Map.Strict as Map
72import qualified Data.Map.Strict as Map
src/Streamly/Streams/Prelude.hs+1−1
@@ -67,7 +67,7 @@ import Control.Monad.Trans (MonadTrans(..))
67import Prelude hiding (foldr)
67import Prelude hiding (foldr)
68import qualified Prelude
68import qualified Prelude
69
69
70−import Streamly.Fold.Types (Fold (..))
70+import Streamly.Internal.Data.Fold.Types (Fold (..))
71
71
72#ifdef USE_STREAMK_ONLY
72#ifdef USE_STREAMK_ONLY
73import qualified Streamly.Streams.StreamK as S
73import qualified Streamly.Streams.StreamK as S
src/Streamly/Streams/StreamD.hs+1−1
@@ -299,7 +299,7 @@ import Prelude
299import qualified Control.Monad.Catch as MC
299import qualified Control.Monad.Catch as MC
300
300
301import Streamly.Memory.Array.Types (Array(..))
301import Streamly.Memory.Array.Types (Array(..))
302−import Streamly.Fold.Types (Fold(..))
302+import Streamly.Internal.Data.Fold.Types (Fold(..))
303import Streamly.Pipe.Types (Pipe(..), PipeState(..))
303import Streamly.Pipe.Types (Pipe(..), PipeState(..))
304import Streamly.SVar (MonadAsync, defState, adaptState)
304import Streamly.SVar (MonadAsync, defState, adaptState)
305import Streamly.Unfold.Types (Unfold(..))
305import Streamly.Unfold.Types (Unfold(..))
src/Streamly/Streams/StreamD/Type.hs+1−1
@@ -72,7 +72,7 @@ import GHC.Types (SPEC(..))
72import Prelude hiding (map, mapM, foldr, take, concatMap)
72import Prelude hiding (map, mapM, foldr, take, concatMap)
73
73
74import Streamly.SVar (State(..), adaptState, defState)
74import Streamly.SVar (State(..), adaptState, defState)
75−import Streamly.Fold.Types (Fold(..))
75+import Streamly.Internal.Data.Fold.Types (Fold(..))
76
76
77import qualified Streamly.Streams.StreamK as K
77import qualified Streamly.Streams.StreamK as K
78
78
streamly.cabal+3−3
@@ -288,7 +288,6 @@ library
288 , Streamly.Unfold
288 , Streamly.Unfold
289
289
290 -- Folds
290 -- Folds
291− , Streamly.Fold.Types
292 , Streamly.Fold.Internal
291 , Streamly.Fold.Internal
293 , Streamly.Sink.Types
292 , Streamly.Sink.Types
294 , Streamly.Sink
293 , Streamly.Sink
@@ -308,8 +307,7 @@ library
308 exposed-modules: Streamly.Prelude
307 exposed-modules: Streamly.Prelude
309 , Streamly.Time
308 , Streamly.Time
310 , Streamly
309 , Streamly
311− , Streamly.Fold
310+ , Streamly.Data.Fold
312−
313 , Streamly.Data.String
311 , Streamly.Data.String
314
312
315 -- IO devices
313 -- IO devices
@@ -321,6 +319,8 @@ library
321 -- Internal modules
319 -- Internal modules
322 , Streamly.Internal
320 , Streamly.Internal
323 , Streamly.Internal.Memory.ArrayStream
321 , Streamly.Internal.Memory.ArrayStream
322+ , Streamly.Internal.Data.Fold
323+ , Streamly.Internal.Data.Fold.Types
324 , Streamly.Internal.Prelude
324 , Streamly.Internal.Prelude
325 if !impl(ghcjs)
325 if !impl(ghcjs)
326 exposed-modules:
326 exposed-modules:
test/Prop.hs+1−1
@@ -32,7 +32,7 @@ import Test.Hspec as H
32import Streamly
32import Streamly
33import Streamly.Prelude ((.:), nil)
33import Streamly.Prelude ((.:), nil)
34import qualified Streamly.Prelude as S
34import qualified Streamly.Prelude as S
35−import qualified Streamly.Fold as FL
35+import qualified Streamly.Data.Fold as FL
36
36
37-- Coverage build takes too long with default number of tests
37-- Coverage build takes too long with default number of tests
38maxTestCount :: Int
38maxTestCount :: Int