on master help sign in
Move Streamly.Fold module

* Move exposed Streamly.Fold to Streamly.Data.Fold * Move the internal implementation to Streamly.Inetrnal.Data.Fold

commit042b677592fd8c6c6e0b2e2c270a2f106078d11a authorHarendra Kumar <harendra.kumar@gmail.com> dateSun 22 Sep 2019, 21:35 (7 years ago) parenta8dd99d
28 files changed+290−65
benchmark/Linear.hs+1−1 benchmark/NanoBenchmarks.hs+1−1 examples/HandleIO.hs+1−1 examples/WordClassifier.hs+1−1 src/Streamly.hs+2−2 src/Streamly/Benchmark/FileIO/Stream.hs+2−2 src/Streamly/Data/Fold.hs+247 src/Streamly/Data/String.hs+1−1 src/Streamly/FileSystem/FD.hs+1−1 src/Streamly/FileSystem/File.hs+1−1 src/Streamly/FileSystem/Handle.hs+3−3 src/Streamly/Fold/Internal.hs+1−1 src/Streamly/Internal.hs+2−2 src/Streamly/Internal/Data/Fold.hs+3−25 src/Streamly/Internal/Data/Fold/Types.hs+2−2 src/Streamly/Internal/Prelude.hs+3−3 src/Streamly/Memory/Array.hs+1−1 src/Streamly/Memory/Array/Types.hs+1−1 src/Streamly/Network/Client.hs+2−2 src/Streamly/Network/Socket.hs+3−3 src/Streamly/Pipe.hs+2−2 src/Streamly/Prelude.hs+1−1 src/Streamly/Sink.hs+1−1 src/Streamly/Streams/Prelude.hs+1−1 src/Streamly/Streams/StreamD.hs+1−1 src/Streamly/Streams/StreamD/Type.hs+1−1 streamly.cabal+3−3 test/Prop.hs+1−1
benchmark/Linear.hs+1−1
@@ -19,7 +19,7 @@ import qualified GHC.Exts as GHC
1919import qualified Streamly.Benchmark.Prelude as Ops
2020
2121import Streamly
22−import qualified Streamly.Fold as FL
22+import qualified Streamly.Data.Fold as FL
2323import qualified Streamly.Internal as Internal
2424import qualified Streamly.Internal.Prelude as IP
2525--import qualified Streamly.Pipe as Pipe
benchmark/NanoBenchmarks.hs+1−1
@@ -11,7 +11,7 @@ import Streamly.SVar (MonadAsync)
1111
1212import qualified Streamly.Memory.Array as A
1313import qualified Streamly.FileSystem.Handle as FH
14−import qualified Streamly.Fold as FL
14+import qualified Streamly.Data.Fold as FL
1515import qualified Streamly.Internal.Prelude as Internal
1616import qualified Streamly.Prelude as S
1717import qualified Streamly.Streams.StreamK as K
examples/HandleIO.hs+1−1
@@ -1,5 +1,5 @@
11import qualified Streamly.Prelude as S
2−import qualified Streamly.Fold as FL
2+import qualified Streamly.Data.Fold as FL
33import qualified Streamly.Memory.Array as A
44import qualified Streamly.FileSystem.Handle as FH
55import qualified System.IO as FH
examples/WordClassifier.hs+1−1
@@ -18,7 +18,7 @@ import qualified Data.Ord as Ord
1818import Foreign.Storable (Storable(..))
1919import qualified Streamly.Data.String as Streamly
2020import qualified Streamly.FileSystem.Handle as FH
21−import qualified Streamly.Fold as FL
21+import qualified Streamly.Data.Fold as FL
2222import qualified Streamly.Internal as Streamly
2323import qualified Streamly.Memory.Array as A
2424import qualified Streamly.Prelude as Streamly
src/Streamly.hs+2−2
@@ -235,7 +235,7 @@ import qualified Streamly.Streams.StreamK as K
235235-- In the following example, a 'Word8' stream is generated by using
236236-- 'Streamly.FileSystem.Handle.read' on a file handle, then the
237237-- '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
239239-- the resulting lines to unit values (@()@), 'Streamly.Prelude.length' fold
240240-- then counts the unit elements in the resulting stream which gives us the
241241-- number of lines in the file:
@@ -267,7 +267,7 @@ import qualified Streamly.Streams.StreamK as K
267267-- $folds
268268--
269269-- 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
271271-- reducers of streams. Reducers can be combined to consume a stream source in
272272-- many ways. The simplest is to reduce a stream source using a fold e.g.:
273273--
src/Streamly/Benchmark/FileIO/Stream.hs+2−2
@@ -59,8 +59,8 @@ import qualified Streamly.FileSystem.Handle as FH
5959import qualified Streamly.FileSystem.Handle.Internal as FH
6060import qualified Streamly.Memory.Array as A
6161import qualified Streamly.Memory.Array.Types as AT
62−import qualified Streamly.Internal.Prelude as S
63−import qualified Streamly.Fold as FL
62+import qualified Streamly.Prelude as S
63+import qualified Streamly.Data.Fold as FL
6464import qualified Streamly.Data.String as SS
6565import qualified Streamly.Internal as Internal
6666import 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)
8989import GHC.Base (unsafeChr)
9090import Streamly (IsStream, MonadAsync)
9191import Prelude hiding (String, lines, words, unlines, unwords)
92−import Streamly.Fold (Fold)
92+import Streamly.Data.Fold (Fold)
9393import Streamly.Memory.Array (Array)
9494import Streamly.Unfold (Unfold)
9595
src/Streamly/FileSystem/FD.hs+1−1
@@ -146,7 +146,7 @@ import Streamly.Streams.StreamD (toStreamD)
146146import Streamly.Streams.StreamD.Type (fromStreamD)
147147import qualified Streamly.FileSystem.FDIO as RawIO hiding (write)
148148#endif
149−-- import Streamly.Fold (Fold)
149+-- import Streamly.Data.Fold (Fold)
150150-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
151151
152152import qualified Streamly.Memory.Array as A
src/Streamly/FileSystem/File.hs+1−1
@@ -119,7 +119,7 @@ import Streamly.Memory.Array.Types (Array(..), defaultChunkSize)
119119import Streamly.Streams.Serial (SerialT)
120120import Streamly.Streams.StreamK.Type (IsStream)
121121import Streamly.SVar (MonadAsync)
122−-- import Streamly.Fold (Fold)
122+-- import Streamly.Data.Fold (Fold)
123123-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
124124
125125import qualified Streamly.FileSystem.Handle as FH
src/Streamly/FileSystem/Handle.hs+3−3
@@ -123,11 +123,11 @@ import Streamly.Memory.Array.Types (Array(..), writeNUnsafe)
123123import Streamly.Streams.StreamK.Type (IsStream, mkStream)
124124import Streamly.Memory.Array.Types
125125 (defaultChunkSize, shrinkToFit, lpackArraysChunksOf)
126−import Streamly.Fold (Fold)
126+import Streamly.Data.Fold (Fold)
127127-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
128128
129−import qualified Streamly.Fold as FL
130−import qualified Streamly.Fold.Types as FL
129+import qualified Streamly.Data.Fold as FL
130+import qualified Streamly.Internal.Data.Fold.Types as FL
131131import qualified Streamly.Memory.Array as A
132132import qualified Streamly.Internal.Memory.ArrayStream as AS
133133import qualified Streamly.Streams.StreamD.Type as D
src/Streamly/Fold/Internal.hs+1−1
@@ -24,7 +24,7 @@ module Streamly.Fold.Internal
2424 )
2525where
2626
27−import Streamly.Fold.Types (Fold(..))
27+import Streamly.Internal.Data.Fold.Types (Fold(..))
2828
2929-- | Compute an 'Int' sized polynomial rolling hash
3030--
src/Streamly/Internal.hs+2−2
@@ -21,7 +21,7 @@ module Streamly.Internal
2121 -- * Diagnostics
2222 inspectMode
2323
24− -- * Streamly.Fold Experimental Exports
24+ -- * Streamly.Internal.Data.Fold Experimental Exports
2525 , Fold (..)
2626 , toListRevF
2727 , rollingHash
@@ -56,4 +56,4 @@ import Streamly.Unfold.Types (Unfold(..))
5656import Streamly.Unfold (fromList)
5757
5858import 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 @@
77{-# LANGUAGE ScopedTypeVariables #-}
88
99-- |
10−-- Module : Streamly.Fold
10+-- Module : Streamly.Internal.Data.Fold
1111-- Copyright : (c) 2019 Composewell Technologies
1212-- (c) 2013 Gabriel Gonzalez
1313-- License : BSD3
1414-- Maintainer : harendra.kumar@gmail.com
1515-- Stability : experimental
1616-- 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
3917
4018-- Also see the "Streamly.Sink" module that provides specialized left folds
4119-- that discard the outputs.
4220--
4321-- IMPORTANT: keep the signatures consistent with the folds in Streamly.Prelude
4422
45−module Streamly.Fold
23+module Streamly.Internal.Data.Fold
4624 (
4725 -- * Fold Type
4826 -- |
@@ -258,7 +236,7 @@ import Prelude
258236import qualified Data.Map.Strict as Map
259237import qualified Prelude
260238
261−import Streamly.Fold.Types (Fold(..), lmap)
239+import Streamly.Internal.Data.Fold.Types (Fold(..), lmap)
262240import Streamly.Pipe.Types (Pipe (..), PipeState(..))
263241import Streamly.Strict
264242
src/Streamly/Internal/Data/Fold/Types.hs+2−2
@@ -3,7 +3,7 @@
33{-# LANGUAGE FlexibleContexts #-}
44
55-- |
6−-- Module : Streamly.Fold.Types
6+-- Module : Streamly.Internal.Data.Fold.Types
77-- Copyright : (c) 2019 Composewell Technologies
88-- (c) 2013 Gabriel Gonzalez
99-- License : BSD3
@@ -11,7 +11,7 @@
1111-- Stability : experimental
1212-- Portability : GHC
1313
14−module Streamly.Fold.Types
14+module Streamly.Internal.Data.Fold.Types
1515 ( Fold (..)
1616 , toListRevF -- experimental
1717 , lmap
src/Streamly/Internal/Prelude.hs+3−3
@@ -403,7 +403,7 @@ import qualified Prelude
403403import qualified System.IO as IO
404404
405405import Streamly.Enumeration (Enumerable(..), enumerate, enumerateTo)
406−import Streamly.Fold.Types (Fold (..))
406+import Streamly.Internal.Data.Fold.Types (Fold (..))
407407import Streamly.Unfold.Types (Unfold)
408408import Streamly.Memory.Array.Types (Array, writeNUnsafe)
409409-- import Streamly.Memory.Ring (Ring)
@@ -423,8 +423,8 @@ import Streamly.Time.Units
423423import Streamly.Strict
424424
425425import qualified Streamly.Memory.Array.Types as A
426−import qualified Streamly.Fold as FL
427−import qualified Streamly.Fold.Types as FL
426+import qualified Streamly.Data.Fold as FL
427+import qualified Streamly.Internal.Data.Fold.Types as FL
428428import qualified Streamly.Streams.Prelude as P
429429import qualified Streamly.Streams.StreamK as K
430430import 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)
146146import Streamly.Memory.Array.Types (Array(..), length)
147147import Streamly.Streams.Serial (SerialT)
148148import Streamly.Streams.StreamK.Type (IsStream)
149−import Streamly.Fold.Types (Fold(..))
149+import Streamly.Internal.Data.Fold.Types (Fold(..))
150150
151151import qualified Streamly.Memory.Array.Types as A
152152import qualified Streamly.Internal.Memory.ArrayStream as AS
src/Streamly/Memory/Array/Types.hs+1−1
@@ -110,7 +110,7 @@ import GHC.ForeignPtr (ForeignPtr(..), newForeignPtr_)
110110import GHC.IO (IO(IO), unsafePerformIO)
111111import GHC.Ptr (Ptr(..))
112112
113−import Streamly.Fold.Types (Fold(..))
113+import Streamly.Internal.Data.Fold.Types (Fold(..))
114114import Streamly.Unfold.Types (Unfold(..))
115115import Streamly.Strict (Tuple'(..))
116116import Streamly.SVar (adaptState)
src/Streamly/Network/Client.hs+2−2
@@ -66,13 +66,13 @@ import Prelude hiding (read)
6666import qualified Network.Socket as Net
6767
6868import Streamly (MonadAsync)
69−import Streamly.Fold.Types (Fold(..))
69+import Streamly.Internal.Data.Fold.Types (Fold(..))
7070import Streamly.Memory.Array.Types (Array(..), defaultChunkSize, writeNUnsafe)
7171-- import Streamly.Streams.Serial (SerialT)
7272import Streamly.Streams.StreamK.Type (IsStream)
7373
74−import qualified Streamly.Fold.Types as FL
7574import qualified Streamly.Internal.Memory.ArrayStream as AS
75+import qualified Streamly.Internal.Data.Fold.Types as FL
7676import qualified Streamly.Prelude as S
7777import qualified Streamly.Network.Socket as SK
7878
src/Streamly/Network/Socket.hs+3−3
@@ -89,11 +89,11 @@ import qualified Network.Socket as Net
8989import Streamly.Memory.Array.Types (Array(..))
9090import Streamly.Streams.Serial (SerialT)
9191import Streamly.Streams.StreamK.Type (IsStream, mkStream)
92−import Streamly.Fold (Fold)
92+import Streamly.Data.Fold (Fold)
9393-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
9494
95−import qualified Streamly.Fold as FL
96−import qualified Streamly.Fold.Types as FL
95+import qualified Streamly.Data.Fold as FL
96+import qualified Streamly.Internal.Data.Fold.Types as FL
9797import qualified Streamly.Memory.Array as A
9898import qualified Streamly.Internal.Memory.ArrayStream as AS
9999import qualified Streamly.Memory.Array.Types as A
src/Streamly/Pipe.hs+2−2
@@ -15,7 +15,7 @@
1515-- Portability : GHC
1616--
1717-- 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").
1919-- Streams are sources or producers of values, multiple sources can be merged
2020-- into a single source but a source cannot be split into multiple stream
2121-- sources. Folds are sinks or consumers, a stream can be split and
@@ -251,7 +251,7 @@ import Prelude
251251-- import qualified Prelude
252252
253253-- import Streamly (MonadAsync, parallel)
254−-- import Streamly.Fold.Types (Fold(..))
254+-- import Streamly.Data.Fold.Types (Fold(..))
255255import Streamly.Pipe.Types
256256 (Pipe(..), PipeState(..), Step(..), zipWith, tee, map, compose)
257257-- import Streamly.Memory.Array.Types (Array)
src/Streamly/Prelude.hs+1−1
@@ -884,7 +884,7 @@ import Streamly.Internal.Prelude
884884
885885-- $runningfolds
886886--
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
888888-- together in many interesting ways. Those folds can be run using 'runFold'.
889889-- The following two ways of folding are equivalent in functionality and
890890-- performance,
src/Streamly/Sink.hs+1−1
@@ -66,7 +66,7 @@ import Prelude
6666 reverse, iterate, init, and, or, lookup, foldr1, (!!),
6767 scanl, scanl1, replicate, concatMap, mconcat, foldMap, unzip)
6868
69−import Streamly.Fold.Types (Fold(..))
69+import Streamly.Internal.Data.Fold.Types (Fold(..))
7070import Streamly.Sink.Types (Sink(..))
7171
7272import qualified Data.Map.Strict as Map
src/Streamly/Streams/Prelude.hs+1−1
@@ -67,7 +67,7 @@ import Control.Monad.Trans (MonadTrans(..))
6767import Prelude hiding (foldr)
6868import qualified Prelude
6969
70−import Streamly.Fold.Types (Fold (..))
70+import Streamly.Internal.Data.Fold.Types (Fold (..))
7171
7272#ifdef USE_STREAMK_ONLY
7373import qualified Streamly.Streams.StreamK as S
src/Streamly/Streams/StreamD.hs+1−1
@@ -299,7 +299,7 @@ import Prelude
299299import qualified Control.Monad.Catch as MC
300300
301301import Streamly.Memory.Array.Types (Array(..))
302−import Streamly.Fold.Types (Fold(..))
302+import Streamly.Internal.Data.Fold.Types (Fold(..))
303303import Streamly.Pipe.Types (Pipe(..), PipeState(..))
304304import Streamly.SVar (MonadAsync, defState, adaptState)
305305import Streamly.Unfold.Types (Unfold(..))
src/Streamly/Streams/StreamD/Type.hs+1−1
@@ -72,7 +72,7 @@ import GHC.Types (SPEC(..))
7272import Prelude hiding (map, mapM, foldr, take, concatMap)
7373
7474import Streamly.SVar (State(..), adaptState, defState)
75−import Streamly.Fold.Types (Fold(..))
75+import Streamly.Internal.Data.Fold.Types (Fold(..))
7676
7777import qualified Streamly.Streams.StreamK as K
7878
streamly.cabal+3−3
@@ -288,7 +288,6 @@ library
288288 , Streamly.Unfold
289289
290290 -- Folds
291− , Streamly.Fold.Types
292291 , Streamly.Fold.Internal
293292 , Streamly.Sink.Types
294293 , Streamly.Sink
@@ -308,8 +307,7 @@ library
308307 exposed-modules: Streamly.Prelude
309308 , Streamly.Time
310309 , Streamly
311− , Streamly.Fold
312−
310+ , Streamly.Data.Fold
313311 , Streamly.Data.String
314312
315313 -- IO devices
@@ -321,6 +319,8 @@ library
321319 -- Internal modules
322320 , Streamly.Internal
323321 , Streamly.Internal.Memory.ArrayStream
322+ , Streamly.Internal.Data.Fold
323+ , Streamly.Internal.Data.Fold.Types
324324 , Streamly.Internal.Prelude
325325 if !impl(ghcjs)
326326 exposed-modules:
test/Prop.hs+1−1
@@ -32,7 +32,7 @@ import Test.Hspec as H
3232import Streamly
3333import Streamly.Prelude ((.:), nil)
3434import qualified Streamly.Prelude as S
35−import qualified Streamly.Fold as FL
35+import qualified Streamly.Data.Fold as FL
3636
3737-- Coverage build takes too long with default number of tests
3838maxTestCount :: Int