on master help sign in
Rename Unfold.concat to Unfold.many #985
commit7759cc0082be36201f740fe056383b97fcf5c0e6 authorRanjeet Kumar Ranjan <ranjeetr@composewell.com> dateThu 18 Mar 2021, 17:34 (6 years ago) parent8be2c1c
13 files changed+33−33
benchmark/Streamly/Benchmark/Data/Unfold.hs+1−1 benchmark/Streamly/Benchmark/FileSystem/Handle/Read.hs+5−5 benchmark/Streamly/Benchmark/FileSystem/Handle/ReadWrite.hs+5−5 benchmark/Streamly/Benchmark/Prelude/Serial/Split.hs+4−4 benchmark/Streamly/Benchmark/Unicode/Stream.hs+2−2 src/Streamly/Internal/Data/Unfold.hs+3−3 src/Streamly/Internal/Data/Unfold/Type.hs+7−7 src/Streamly/Internal/FileSystem/Dir.hs+1−1 src/Streamly/Internal/FileSystem/File.hs+1−1 src/Streamly/Internal/FileSystem/Handle.hs+1−1 src/Streamly/Internal/Network/Inet/TCP.hs+1−1 src/Streamly/Internal/Network/Socket.hs+1−1 test/Streamly/Test/Data/Unfold.hs+1−1
benchmark/Streamly/Benchmark/Data/Unfold.hs+1−1
@@ -559,7 +559,7 @@ concat :: Monad m => Int -> Int -> m ()
559559concat linearCount start = do
560560 let end = start + concatCount linearCount
561561 UF.fold
562− (UF.concat (source end) (source end))
562+ (UF.many (source end) (source end))
563563 FL.drain start
564564
565565-------------------------------------------------------------------------------
benchmark/Streamly/Benchmark/FileSystem/Handle/Read.hs+5−5
@@ -161,7 +161,7 @@ readLast = S.last . S.unfold FH.read
161161#ifdef INSPECTION
162162inspect $ hasNoTypeClasses 'readLast
163163inspect $ 'readLast `hasNoType` ''Step -- S.unfold
164−inspect $ 'readLast `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
164+inspect $ 'readLast `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
165165inspect $ 'readLast `hasNoType` ''MA.ReadUState -- FH.read/A.read
166166#endif
167167
@@ -173,7 +173,7 @@ readCountBytes = S.length . S.unfold FH.read
173173#ifdef INSPECTION
174174inspect $ hasNoTypeClasses 'readCountBytes
175175inspect $ 'readCountBytes `hasNoType` ''Step -- S.unfold
176−inspect $ 'readCountBytes `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
176+inspect $ 'readCountBytes `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
177177inspect $ 'readCountBytes `hasNoType` ''MA.ReadUState -- FH.read/A.read
178178#endif
179179
@@ -188,7 +188,7 @@ readCountLines =
188188#ifdef INSPECTION
189189inspect $ hasNoTypeClasses 'readCountLines
190190inspect $ 'readCountLines `hasNoType` ''Step
191−inspect $ 'readCountLines `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
191+inspect $ 'readCountLines `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
192192inspect $ 'readCountLines `hasNoType` ''MA.ReadUState -- FH.read/A.read
193193#endif
194194
@@ -212,7 +212,7 @@ readSumBytes = S.sum . S.unfold FH.read
212212#ifdef INSPECTION
213213inspect $ hasNoTypeClasses 'readSumBytes
214214inspect $ 'readSumBytes `hasNoType` ''Step
215−inspect $ 'readSumBytes `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
215+inspect $ 'readSumBytes `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
216216inspect $ 'readSumBytes `hasNoType` ''MA.ReadUState -- FH.read/A.read
217217#endif
218218
@@ -332,7 +332,7 @@ inspect $ hasNoTypeClasses 'chunksOf
332332inspect $ 'chunksOf `hasNoType` ''Step
333333inspect $ 'chunksOf `hasNoType` ''FoldMany
334334inspect $ 'chunksOf `hasNoType` ''AT.ArrayUnsafe -- AT.writeNUnsafe
335−inspect $ 'chunksOf `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
335+inspect $ 'chunksOf `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
336336inspect $ 'chunksOf `hasNoType` ''MA.ReadUState -- FH.read/A.read
337337#endif
338338
benchmark/Streamly/Benchmark/FileSystem/Handle/ReadWrite.hs+5−5
@@ -83,7 +83,7 @@ copyStream inh outh = S.fold (FH.write outh) (S.unfold FH.read inh)
8383#ifdef INSPECTION
8484inspect $ hasNoTypeClasses 'copyStream
8585inspect $ 'copyStream `hasNoType` ''Step -- S.unfold
86−inspect $ 'copyStream `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
86+inspect $ 'copyStream `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
8787inspect $ 'copyStream `hasNoType` ''MA.ReadUState -- FH.read/A.read
8888inspect $ 'copyStream `hasNoType` ''AT.ArrayUnsafe -- FH.write/writeNUnsafe
8989inspect $ 'copyStream `hasNoType` ''Strict.Tuple3' -- FH.write/chunksOf
@@ -137,7 +137,7 @@ _readChunks inh devNull = IUF.fold unf fld inh
137137 where
138138
139139 fld = FH.write devNull
140− unf = IUF.concat FH.readChunks A.read
140+ unf = IUF.many FH.readChunks A.read
141141
142142-- | Send the chunk content to /dev/null
143143-- Implicitly benchmarked via 'readWithBufferOfFromBytesNull'
@@ -147,7 +147,7 @@ _readChunksWithBufferOf inh devNull = IUF.fold unf fld (defaultChunkSize, inh)
147147 where
148148
149149 fld = FH.write devNull
150− unf = IUF.concat FH.readChunksWithBufferOf A.read
150+ unf = IUF.many FH.readChunksWithBufferOf A.read
151151
152152
153153o_1_space_copy_fromBytes :: BenchEnv -> [Benchmark]
@@ -173,7 +173,7 @@ writeReadWithBufferOf inh devNull = IUF.fold unf fld (defaultChunkSize, inh)
173173#ifdef INSPECTION
174174inspect $ hasNoTypeClasses 'writeReadWithBufferOf
175175inspect $ 'writeReadWithBufferOf `hasNoType` ''Step
176−inspect $ 'writeReadWithBufferOf `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
176+inspect $ 'writeReadWithBufferOf `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
177177inspect $ 'writeReadWithBufferOf `hasNoType` ''MA.ReadUState -- FH.read/A.read
178178inspect $ 'writeReadWithBufferOf `hasNoType` ''AT.ArrayUnsafe -- FH.write/writeNUnsafe
179179#endif
@@ -191,7 +191,7 @@ writeRead inh devNull = IUF.fold unf fld inh
191191#ifdef INSPECTION
192192inspect $ hasNoTypeClasses 'writeRead
193193inspect $ 'writeRead `hasNoType` ''Step
194−inspect $ 'writeRead `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
194+inspect $ 'writeRead `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
195195inspect $ 'writeRead `hasNoType` ''MA.ReadUState -- FH.read/A.read
196196inspect $ 'writeRead `hasNoType` ''AT.ArrayUnsafe -- FH.write/writeNUnsafe
197197#endif
benchmark/Streamly/Benchmark/Prelude/Serial/Split.hs+4−4
@@ -66,7 +66,7 @@ splitOn inh =
6666#ifdef INSPECTION
6767inspect $ hasNoTypeClasses 'splitOn
6868inspect $ 'splitOn `hasNoType` ''Step
69−inspect $ 'splitOn `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
69+inspect $ 'splitOn `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
7070inspect $ 'splitOn `hasNoType` ''MA.ReadUState -- FH.read/A.read
7171#endif
7272
@@ -79,7 +79,7 @@ splitOnSuffix inh =
7979#ifdef INSPECTION
8080inspect $ hasNoTypeClasses 'splitOnSuffix
8181inspect $ 'splitOnSuffix `hasNoType` ''Step
82−inspect $ 'splitOnSuffix `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
82+inspect $ 'splitOnSuffix `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
8383inspect $ 'splitOnSuffix `hasNoType` ''MA.ReadUState -- FH.read/A.read
8484#endif
8585
@@ -92,7 +92,7 @@ splitWithSuffix inh =
9292#ifdef INSPECTION
9393inspect $ hasNoTypeClasses 'splitWithSuffix
9494inspect $ 'splitWithSuffix `hasNoType` ''Step
95−inspect $ 'splitWithSuffix `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
95+inspect $ 'splitWithSuffix `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
9696inspect $ 'splitWithSuffix `hasNoType` ''MA.ReadUState -- FH.read/A.read
9797#endif
9898
@@ -123,7 +123,7 @@ wordsBy inh =
123123#ifdef INSPECTION
124124inspect $ hasNoTypeClasses 'wordsBy
125125inspect $ 'wordsBy `hasNoType` ''Step
126−inspect $ 'wordsBy `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
126+inspect $ 'wordsBy `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
127127inspect $ 'wordsBy `hasNoType` ''MA.ReadUState -- FH.read/A.read
128128#endif
129129
benchmark/Streamly/Benchmark/Unicode/Stream.hs+2−2
@@ -209,7 +209,7 @@ copyStreamLatin1' inh outh =
209209#ifdef INSPECTION
210210inspect $ hasNoTypeClasses 'copyStreamLatin1'
211211inspect $ 'copyStreamLatin1' `hasNoType` ''Step
212−inspect $ 'copyStreamLatin1' `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
212+inspect $ 'copyStreamLatin1' `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
213213inspect $ 'copyStreamLatin1' `hasNoType` ''MA.ReadUState -- FH.read/A.read
214214
215215inspect $ 'copyStreamLatin1' `hasNoType` ''Fold.Step
@@ -229,7 +229,7 @@ copyStreamLatin1 inh outh =
229229#ifdef INSPECTION
230230inspect $ hasNoTypeClasses 'copyStreamLatin1
231231inspect $ 'copyStreamLatin1 `hasNoType` ''Step
232−inspect $ 'copyStreamLatin1 `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
232+inspect $ 'copyStreamLatin1 `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
233233inspect $ 'copyStreamLatin1 `hasNoType` ''MA.ReadUState -- FH.read/A.read
234234
235235inspect $ 'copyStreamLatin1 `hasNoType` ''Fold.ManyState
src/Streamly/Internal/Data/Unfold.hs+3−3
@@ -150,7 +150,7 @@ module Streamly.Internal.Data.Unfold
150150
151151 -- * Nesting
152152 , ConcatState (..)
153− , concat
153+ , many
154154 , concatMapM
155155 , outerProduct
156156
@@ -196,7 +196,7 @@ import qualified Streamly.Internal.Data.Stream.StreamK.Type as K
196196import Streamly.Internal.Data.SVar
197197import Streamly.Internal.Data.Unfold.Type
198198import Prelude
199− hiding (concat, map, mapM, takeWhile, take, filter, const, zipWith
199+ hiding (map, mapM, takeWhile, take, filter, const, zipWith
200200 , drop, dropWhile)
201201
202202-------------------------------------------------------------------------------
@@ -206,7 +206,7 @@ import Prelude
206206-- | Map an action on the input argument of the 'Unfold'.
207207--
208208-- @
209−-- lmapM f = concat (singletonM f)
209+-- lmapM f = many (singletonM f)
210210-- @
211211--
212212-- /Pre-release/
src/Streamly/Internal/Data/Unfold/Type.hs+7−7
@@ -12,7 +12,7 @@ module Streamly.Internal.Data.Unfold.Type
1212 , singleton
1313 , identity
1414 , ConcatState (..)
15− , concat
15+ , many
1616 , lmap
1717 , map
1818 , const
@@ -33,7 +33,7 @@ import Control.Category (Category(..))
3333import Fusion.Plugin.Types (Fuse(..))
3434import Streamly.Internal.Data.Stream.StreamD.Step (Step(..))
3535
36−import Prelude hiding (const, map, concat, concatMap, zipWith)
36+import Prelude hiding (const, map, concatMap, zipWith)
3737
3838-- $setup
3939-- >>> :m
@@ -60,7 +60,7 @@ data Unfold m a b =
6060-- | Map a function on the input argument of the 'Unfold'.
6161--
6262-- @
63−-- lmap f = concat (singleton f)
63+-- lmap f = many (singleton f)
6464-- @
6565--
6666-- /Pre-release/
@@ -279,9 +279,9 @@ data ConcatState s1 s2 = ConcatOuter s1 | ConcatInner s1 s2
279279--
280280-- /Pre-release/
281281--
282−{-# INLINE_NORMAL concat #-}
283−concat :: Monad m => Unfold m a b -> Unfold m b c -> Unfold m a c
284−concat (Unfold step1 inject1) (Unfold step2 inject2) = Unfold step inject
282+{-# INLINE_NORMAL many #-}
283+many :: Monad m => Unfold m a b -> Unfold m b c -> Unfold m a c
284+many (Unfold step1 inject1) (Unfold step2 inject2) = Unfold step inject
285285
286286 where
287287
@@ -311,7 +311,7 @@ instance Monad m => Category (Unfold m) where
311311 id = identity
312312
313313 {-# INLINE (.) #-}
314− (.) = flip concat
314+ (.) = flip many
315315
316316-------------------------------------------------------------------------------
317317-- Arrow
src/Streamly/Internal/FileSystem/Dir.hs+1−1
@@ -189,7 +189,7 @@ readChunks = UF.supplyFirst readChunksWithBufferOf defaultChunkSize
189189-- @since 0.7.0
190190{-# INLINE readWithBufferOf #-}
191191readWithBufferOf :: MonadIO m => Unfold m (Int, Handle) Word8
192−readWithBufferOf = UF.concat readChunksWithBufferOf A.read
192+readWithBufferOf = UF.many readChunksWithBufferOf A.read
193193
194194-- | @toStreamWithBufferOf bufsize handle@ reads a byte stream from a file
195195-- handle, reads are performed in chunks of up to @bufsize@.
src/Streamly/Internal/FileSystem/File.hs+1−1
@@ -267,7 +267,7 @@ readWithBufferOf = usingFile2 FH.readWithBufferOf
267267-- @since 0.7.0
268268{-# INLINE read #-}
269269read :: (MonadCatch m, MonadAsync m) => Unfold m FilePath Word8
270−read = UF.concat (usingFile FH.readChunks) A.read
270+read = UF.many (usingFile FH.readChunks) A.read
271271
272272-- | Generate a stream of bytes from a file specified by path. The stream ends
273273-- when EOF is encountered. File is locked using multiple reader and single
src/Streamly/Internal/FileSystem/Handle.hs+1−1
@@ -278,7 +278,7 @@ readChunks = UF.supplyFirst readChunksWithBufferOf defaultChunkSize
278278-- @since 0.7.0
279279{-# INLINE readWithBufferOf #-}
280280readWithBufferOf :: MonadIO m => Unfold m (Int, Handle) Word8
281−readWithBufferOf = UF.concat readChunksWithBufferOf A.read
281+readWithBufferOf = UF.many readChunksWithBufferOf A.read
282282
283283-- | @toBytesWithBufferOf bufsize handle@ reads a byte stream from a file
284284-- handle, reads are performed in chunks of up to @bufsize@.
src/Streamly/Internal/Network/Inet/TCP.hs+1−1
@@ -314,7 +314,7 @@ withConnection addr port =
314314{-# INLINE read #-}
315315read :: (MonadCatch m, MonadAsync m)
316316 => Unfold m ((Word8, Word8, Word8, Word8), PortNumber) Word8
317−read = UF.concat (usingConnection ISK.readChunks) A.read
317+read = UF.many (usingConnection ISK.readChunks) A.read
318318
319319-- | Read a stream from the supplied IPv4 host address and port number.
320320--
src/Streamly/Internal/Network/Socket.hs+1−1
@@ -425,7 +425,7 @@ toBytes = AS.concat . toChunks
425425-- @since 0.7.0
426426{-# INLINE readWithBufferOf #-}
427427readWithBufferOf :: MonadIO m => Unfold m (Int, Socket) Word8
428−readWithBufferOf = UF.concat readChunksWithBufferOf A.read
428+readWithBufferOf = UF.many readChunksWithBufferOf A.read
429429
430430-- | Unfolds a 'Socket' into a byte stream. IO requests to the socket are
431431-- performed in sizes of
test/Streamly/Test/Data/Unfold.hs+1−1
@@ -333,7 +333,7 @@ concat :: Bool
333333concat =
334334 let unfIn = UF.replicateM 10
335335 unfOut = UF.map return $ UF.enumerateFromToIntegral 10
336− unf = UF.concat unfOut unfIn
336+ unf = UF.many unfOut unfIn
337337 lst = Prelude.concat $ Prelude.map (Prelude.replicate 10) [1 .. 10]
338338 in testUnfoldD unf 1 lst
339339