on master help sign in
Rename Unfold.concat to Unfold.many #985
7759cc0Ranjeet Kumar Ranjan
benchmark/Streamly/Benchmark/Data/Unfold.hs+1−1
@@ -559,7 +559,7 @@ concat :: Monad m => Int -> Int -> m ()
559concat linearCount start = do
559concat linearCount start = do
560 let end = start + concatCount linearCount
560 let end = start + concatCount linearCount
561 UF.fold
561 UF.fold
562− (UF.concat (source end) (source end))
562+ (UF.many (source end) (source end))
563 FL.drain start
563 FL.drain start
564
564
565-------------------------------------------------------------------------------
565-------------------------------------------------------------------------------
benchmark/Streamly/Benchmark/FileSystem/Handle/Read.hs+5−5
@@ -161,7 +161,7 @@ readLast = S.last . S.unfold FH.read
161#ifdef INSPECTION
161#ifdef INSPECTION
162inspect $ hasNoTypeClasses 'readLast
162inspect $ hasNoTypeClasses 'readLast
163inspect $ 'readLast `hasNoType` ''Step -- S.unfold
163inspect $ '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
165inspect $ 'readLast `hasNoType` ''MA.ReadUState -- FH.read/A.read
165inspect $ 'readLast `hasNoType` ''MA.ReadUState -- FH.read/A.read
166#endif
166#endif
167
167
@@ -173,7 +173,7 @@ readCountBytes = S.length . S.unfold FH.read
173#ifdef INSPECTION
173#ifdef INSPECTION
174inspect $ hasNoTypeClasses 'readCountBytes
174inspect $ hasNoTypeClasses 'readCountBytes
175inspect $ 'readCountBytes `hasNoType` ''Step -- S.unfold
175inspect $ '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
177inspect $ 'readCountBytes `hasNoType` ''MA.ReadUState -- FH.read/A.read
177inspect $ 'readCountBytes `hasNoType` ''MA.ReadUState -- FH.read/A.read
178#endif
178#endif
179
179
@@ -188,7 +188,7 @@ readCountLines =
188#ifdef INSPECTION
188#ifdef INSPECTION
189inspect $ hasNoTypeClasses 'readCountLines
189inspect $ hasNoTypeClasses 'readCountLines
190inspect $ 'readCountLines `hasNoType` ''Step
190inspect $ 'readCountLines `hasNoType` ''Step
191−inspect $ 'readCountLines `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
191+inspect $ 'readCountLines `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
192inspect $ 'readCountLines `hasNoType` ''MA.ReadUState -- FH.read/A.read
192inspect $ 'readCountLines `hasNoType` ''MA.ReadUState -- FH.read/A.read
193#endif
193#endif
194
194
@@ -212,7 +212,7 @@ readSumBytes = S.sum . S.unfold FH.read
212#ifdef INSPECTION
212#ifdef INSPECTION
213inspect $ hasNoTypeClasses 'readSumBytes
213inspect $ hasNoTypeClasses 'readSumBytes
214inspect $ 'readSumBytes `hasNoType` ''Step
214inspect $ 'readSumBytes `hasNoType` ''Step
215−inspect $ 'readSumBytes `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
215+inspect $ 'readSumBytes `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
216inspect $ 'readSumBytes `hasNoType` ''MA.ReadUState -- FH.read/A.read
216inspect $ 'readSumBytes `hasNoType` ''MA.ReadUState -- FH.read/A.read
217#endif
217#endif
218
218
@@ -332,7 +332,7 @@ inspect $ hasNoTypeClasses 'chunksOf
332inspect $ 'chunksOf `hasNoType` ''Step
332inspect $ 'chunksOf `hasNoType` ''Step
333inspect $ 'chunksOf `hasNoType` ''FoldMany
333inspect $ 'chunksOf `hasNoType` ''FoldMany
334inspect $ 'chunksOf `hasNoType` ''AT.ArrayUnsafe -- AT.writeNUnsafe
334inspect $ '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
336inspect $ 'chunksOf `hasNoType` ''MA.ReadUState -- FH.read/A.read
336inspect $ 'chunksOf `hasNoType` ''MA.ReadUState -- FH.read/A.read
337#endif
337#endif
338
338
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)
83#ifdef INSPECTION
83#ifdef INSPECTION
84inspect $ hasNoTypeClasses 'copyStream
84inspect $ hasNoTypeClasses 'copyStream
85inspect $ 'copyStream `hasNoType` ''Step -- S.unfold
85inspect $ '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
87inspect $ 'copyStream `hasNoType` ''MA.ReadUState -- FH.read/A.read
87inspect $ 'copyStream `hasNoType` ''MA.ReadUState -- FH.read/A.read
88inspect $ 'copyStream `hasNoType` ''AT.ArrayUnsafe -- FH.write/writeNUnsafe
88inspect $ 'copyStream `hasNoType` ''AT.ArrayUnsafe -- FH.write/writeNUnsafe
89inspect $ 'copyStream `hasNoType` ''Strict.Tuple3' -- FH.write/chunksOf
89inspect $ 'copyStream `hasNoType` ''Strict.Tuple3' -- FH.write/chunksOf
@@ -137,7 +137,7 @@ _readChunks inh devNull = IUF.fold unf fld inh
137 where
137 where
138
138
139 fld = FH.write devNull
139 fld = FH.write devNull
140− unf = IUF.concat FH.readChunks A.read
140+ unf = IUF.many FH.readChunks A.read
141
141
142-- | Send the chunk content to /dev/null
142-- | Send the chunk content to /dev/null
143-- Implicitly benchmarked via 'readWithBufferOfFromBytesNull'
143-- Implicitly benchmarked via 'readWithBufferOfFromBytesNull'
@@ -147,7 +147,7 @@ _readChunksWithBufferOf inh devNull = IUF.fold unf fld (defaultChunkSize, inh)
147 where
147 where
148
148
149 fld = FH.write devNull
149 fld = FH.write devNull
150− unf = IUF.concat FH.readChunksWithBufferOf A.read
150+ unf = IUF.many FH.readChunksWithBufferOf A.read
151
151
152
152
153o_1_space_copy_fromBytes :: BenchEnv -> [Benchmark]
153o_1_space_copy_fromBytes :: BenchEnv -> [Benchmark]
@@ -173,7 +173,7 @@ writeReadWithBufferOf inh devNull = IUF.fold unf fld (defaultChunkSize, inh)
173#ifdef INSPECTION
173#ifdef INSPECTION
174inspect $ hasNoTypeClasses 'writeReadWithBufferOf
174inspect $ hasNoTypeClasses 'writeReadWithBufferOf
175inspect $ 'writeReadWithBufferOf `hasNoType` ''Step
175inspect $ 'writeReadWithBufferOf `hasNoType` ''Step
176−inspect $ 'writeReadWithBufferOf `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
176+inspect $ 'writeReadWithBufferOf `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
177inspect $ 'writeReadWithBufferOf `hasNoType` ''MA.ReadUState -- FH.read/A.read
177inspect $ 'writeReadWithBufferOf `hasNoType` ''MA.ReadUState -- FH.read/A.read
178inspect $ 'writeReadWithBufferOf `hasNoType` ''AT.ArrayUnsafe -- FH.write/writeNUnsafe
178inspect $ 'writeReadWithBufferOf `hasNoType` ''AT.ArrayUnsafe -- FH.write/writeNUnsafe
179#endif
179#endif
@@ -191,7 +191,7 @@ writeRead inh devNull = IUF.fold unf fld inh
191#ifdef INSPECTION
191#ifdef INSPECTION
192inspect $ hasNoTypeClasses 'writeRead
192inspect $ hasNoTypeClasses 'writeRead
193inspect $ 'writeRead `hasNoType` ''Step
193inspect $ 'writeRead `hasNoType` ''Step
194−inspect $ 'writeRead `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
194+inspect $ 'writeRead `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
195inspect $ 'writeRead `hasNoType` ''MA.ReadUState -- FH.read/A.read
195inspect $ 'writeRead `hasNoType` ''MA.ReadUState -- FH.read/A.read
196inspect $ 'writeRead `hasNoType` ''AT.ArrayUnsafe -- FH.write/writeNUnsafe
196inspect $ 'writeRead `hasNoType` ''AT.ArrayUnsafe -- FH.write/writeNUnsafe
197#endif
197#endif
benchmark/Streamly/Benchmark/Prelude/Serial/Split.hs+4−4
@@ -66,7 +66,7 @@ splitOn inh =
66#ifdef INSPECTION
66#ifdef INSPECTION
67inspect $ hasNoTypeClasses 'splitOn
67inspect $ hasNoTypeClasses 'splitOn
68inspect $ 'splitOn `hasNoType` ''Step
68inspect $ 'splitOn `hasNoType` ''Step
69−inspect $ 'splitOn `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
69+inspect $ 'splitOn `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
70inspect $ 'splitOn `hasNoType` ''MA.ReadUState -- FH.read/A.read
70inspect $ 'splitOn `hasNoType` ''MA.ReadUState -- FH.read/A.read
71#endif
71#endif
72
72
@@ -79,7 +79,7 @@ splitOnSuffix inh =
79#ifdef INSPECTION
79#ifdef INSPECTION
80inspect $ hasNoTypeClasses 'splitOnSuffix
80inspect $ hasNoTypeClasses 'splitOnSuffix
81inspect $ 'splitOnSuffix `hasNoType` ''Step
81inspect $ 'splitOnSuffix `hasNoType` ''Step
82−inspect $ 'splitOnSuffix `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
82+inspect $ 'splitOnSuffix `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
83inspect $ 'splitOnSuffix `hasNoType` ''MA.ReadUState -- FH.read/A.read
83inspect $ 'splitOnSuffix `hasNoType` ''MA.ReadUState -- FH.read/A.read
84#endif
84#endif
85
85
@@ -92,7 +92,7 @@ splitWithSuffix inh =
92#ifdef INSPECTION
92#ifdef INSPECTION
93inspect $ hasNoTypeClasses 'splitWithSuffix
93inspect $ hasNoTypeClasses 'splitWithSuffix
94inspect $ 'splitWithSuffix `hasNoType` ''Step
94inspect $ 'splitWithSuffix `hasNoType` ''Step
95−inspect $ 'splitWithSuffix `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
95+inspect $ 'splitWithSuffix `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
96inspect $ 'splitWithSuffix `hasNoType` ''MA.ReadUState -- FH.read/A.read
96inspect $ 'splitWithSuffix `hasNoType` ''MA.ReadUState -- FH.read/A.read
97#endif
97#endif
98
98
@@ -123,7 +123,7 @@ wordsBy inh =
123#ifdef INSPECTION
123#ifdef INSPECTION
124inspect $ hasNoTypeClasses 'wordsBy
124inspect $ hasNoTypeClasses 'wordsBy
125inspect $ 'wordsBy `hasNoType` ''Step
125inspect $ 'wordsBy `hasNoType` ''Step
126−inspect $ 'wordsBy `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
126+inspect $ 'wordsBy `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
127inspect $ 'wordsBy `hasNoType` ''MA.ReadUState -- FH.read/A.read
127inspect $ 'wordsBy `hasNoType` ''MA.ReadUState -- FH.read/A.read
128#endif
128#endif
129
129
benchmark/Streamly/Benchmark/Unicode/Stream.hs+2−2
@@ -209,7 +209,7 @@ copyStreamLatin1' inh outh =
209#ifdef INSPECTION
209#ifdef INSPECTION
210inspect $ hasNoTypeClasses 'copyStreamLatin1'
210inspect $ hasNoTypeClasses 'copyStreamLatin1'
211inspect $ 'copyStreamLatin1' `hasNoType` ''Step
211inspect $ 'copyStreamLatin1' `hasNoType` ''Step
212−inspect $ 'copyStreamLatin1' `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
212+inspect $ 'copyStreamLatin1' `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
213inspect $ 'copyStreamLatin1' `hasNoType` ''MA.ReadUState -- FH.read/A.read
213inspect $ 'copyStreamLatin1' `hasNoType` ''MA.ReadUState -- FH.read/A.read
214
214
215inspect $ 'copyStreamLatin1' `hasNoType` ''Fold.Step
215inspect $ 'copyStreamLatin1' `hasNoType` ''Fold.Step
@@ -229,7 +229,7 @@ copyStreamLatin1 inh outh =
229#ifdef INSPECTION
229#ifdef INSPECTION
230inspect $ hasNoTypeClasses 'copyStreamLatin1
230inspect $ hasNoTypeClasses 'copyStreamLatin1
231inspect $ 'copyStreamLatin1 `hasNoType` ''Step
231inspect $ 'copyStreamLatin1 `hasNoType` ''Step
232−inspect $ 'copyStreamLatin1 `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
232+inspect $ 'copyStreamLatin1 `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
233inspect $ 'copyStreamLatin1 `hasNoType` ''MA.ReadUState -- FH.read/A.read
233inspect $ 'copyStreamLatin1 `hasNoType` ''MA.ReadUState -- FH.read/A.read
234
234
235inspect $ 'copyStreamLatin1 `hasNoType` ''Fold.ManyState
235inspect $ 'copyStreamLatin1 `hasNoType` ''Fold.ManyState
src/Streamly/Internal/Data/Unfold.hs+3−3
@@ -150,7 +150,7 @@ module Streamly.Internal.Data.Unfold
150
150
151 -- * Nesting
151 -- * Nesting
152 , ConcatState (..)
152 , ConcatState (..)
153− , concat
153+ , many
154 , concatMapM
154 , concatMapM
155 , outerProduct
155 , outerProduct
156
156
@@ -196,7 +196,7 @@ import qualified Streamly.Internal.Data.Stream.StreamK.Type as K
196import Streamly.Internal.Data.SVar
196import Streamly.Internal.Data.SVar
197import Streamly.Internal.Data.Unfold.Type
197import Streamly.Internal.Data.Unfold.Type
198import Prelude
198import Prelude
199− hiding (concat, map, mapM, takeWhile, take, filter, const, zipWith
199+ hiding (map, mapM, takeWhile, take, filter, const, zipWith
200 , drop, dropWhile)
200 , drop, dropWhile)
201
201
202-------------------------------------------------------------------------------
202-------------------------------------------------------------------------------
@@ -206,7 +206,7 @@ import Prelude
206-- | Map an action on the input argument of the 'Unfold'.
206-- | Map an action on the input argument of the 'Unfold'.
207--
207--
208-- @
208-- @
209−-- lmapM f = concat (singletonM f)
209+-- lmapM f = many (singletonM f)
210-- @
210-- @
211--
211--
212-- /Pre-release/
212-- /Pre-release/
src/Streamly/Internal/Data/Unfold/Type.hs+7−7
@@ -12,7 +12,7 @@ module Streamly.Internal.Data.Unfold.Type
12 , singleton
12 , singleton
13 , identity
13 , identity
14 , ConcatState (..)
14 , ConcatState (..)
15− , concat
15+ , many
16 , lmap
16 , lmap
17 , map
17 , map
18 , const
18 , const
@@ -33,7 +33,7 @@ import Control.Category (Category(..))
33import Fusion.Plugin.Types (Fuse(..))
33import Fusion.Plugin.Types (Fuse(..))
34import Streamly.Internal.Data.Stream.StreamD.Step (Step(..))
34import Streamly.Internal.Data.Stream.StreamD.Step (Step(..))
35
35
36−import Prelude hiding (const, map, concat, concatMap, zipWith)
36+import Prelude hiding (const, map, concatMap, zipWith)
37
37
38-- $setup
38-- $setup
39-- >>> :m
39-- >>> :m
@@ -60,7 +60,7 @@ data Unfold m a b =
60-- | Map a function on the input argument of the 'Unfold'.
60-- | Map a function on the input argument of the 'Unfold'.
61--
61--
62-- @
62-- @
63−-- lmap f = concat (singleton f)
63+-- lmap f = many (singleton f)
64-- @
64-- @
65--
65--
66-- /Pre-release/
66-- /Pre-release/
@@ -279,9 +279,9 @@ data ConcatState s1 s2 = ConcatOuter s1 | ConcatInner s1 s2
279--
279--
280-- /Pre-release/
280-- /Pre-release/
281--
281--
282−{-# INLINE_NORMAL concat #-}
282+{-# INLINE_NORMAL many #-}
283−concat :: Monad m => Unfold m a b -> Unfold m b c -> Unfold m a c
283+many :: 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
284+many (Unfold step1 inject1) (Unfold step2 inject2) = Unfold step inject
285
285
286 where
286 where
287
287
@@ -311,7 +311,7 @@ instance Monad m => Category (Unfold m) where
311 id = identity
311 id = identity
312
312
313 {-# INLINE (.) #-}
313 {-# INLINE (.) #-}
314− (.) = flip concat
314+ (.) = flip many
315
315
316-------------------------------------------------------------------------------
316-------------------------------------------------------------------------------
317-- Arrow
317-- Arrow
src/Streamly/Internal/FileSystem/Dir.hs+1−1
@@ -189,7 +189,7 @@ readChunks = UF.supplyFirst readChunksWithBufferOf defaultChunkSize
189-- @since 0.7.0
189-- @since 0.7.0
190{-# INLINE readWithBufferOf #-}
190{-# INLINE readWithBufferOf #-}
191readWithBufferOf :: MonadIO m => Unfold m (Int, Handle) Word8
191readWithBufferOf :: MonadIO m => Unfold m (Int, Handle) Word8
192−readWithBufferOf = UF.concat readChunksWithBufferOf A.read
192+readWithBufferOf = UF.many readChunksWithBufferOf A.read
193
193
194-- | @toStreamWithBufferOf bufsize handle@ reads a byte stream from a file
194-- | @toStreamWithBufferOf bufsize handle@ reads a byte stream from a file
195-- handle, reads are performed in chunks of up to @bufsize@.
195-- 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
267-- @since 0.7.0
267-- @since 0.7.0
268{-# INLINE read #-}
268{-# INLINE read #-}
269read :: (MonadCatch m, MonadAsync m) => Unfold m FilePath Word8
269read :: (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
271
271
272-- | Generate a stream of bytes from a file specified by path. The stream ends
272-- | Generate a stream of bytes from a file specified by path. The stream ends
273-- when EOF is encountered. File is locked using multiple reader and single
273-- 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
278-- @since 0.7.0
278-- @since 0.7.0
279{-# INLINE readWithBufferOf #-}
279{-# INLINE readWithBufferOf #-}
280readWithBufferOf :: MonadIO m => Unfold m (Int, Handle) Word8
280readWithBufferOf :: MonadIO m => Unfold m (Int, Handle) Word8
281−readWithBufferOf = UF.concat readChunksWithBufferOf A.read
281+readWithBufferOf = UF.many readChunksWithBufferOf A.read
282
282
283-- | @toBytesWithBufferOf bufsize handle@ reads a byte stream from a file
283-- | @toBytesWithBufferOf bufsize handle@ reads a byte stream from a file
284-- handle, reads are performed in chunks of up to @bufsize@.
284-- 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 =
314{-# INLINE read #-}
314{-# INLINE read #-}
315read :: (MonadCatch m, MonadAsync m)
315read :: (MonadCatch m, MonadAsync m)
316 => Unfold m ((Word8, Word8, Word8, Word8), PortNumber) Word8
316 => 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
318
318
319-- | Read a stream from the supplied IPv4 host address and port number.
319-- | Read a stream from the supplied IPv4 host address and port number.
320--
320--
src/Streamly/Internal/Network/Socket.hs+1−1
@@ -425,7 +425,7 @@ toBytes = AS.concat . toChunks
425-- @since 0.7.0
425-- @since 0.7.0
426{-# INLINE readWithBufferOf #-}
426{-# INLINE readWithBufferOf #-}
427readWithBufferOf :: MonadIO m => Unfold m (Int, Socket) Word8
427readWithBufferOf :: MonadIO m => Unfold m (Int, Socket) Word8
428−readWithBufferOf = UF.concat readChunksWithBufferOf A.read
428+readWithBufferOf = UF.many readChunksWithBufferOf A.read
429
429
430-- | Unfolds a 'Socket' into a byte stream. IO requests to the socket are
430-- | Unfolds a 'Socket' into a byte stream. IO requests to the socket are
431-- performed in sizes of
431-- performed in sizes of
test/Streamly/Test/Data/Unfold.hs+1−1
@@ -333,7 +333,7 @@ concat :: Bool
333concat =
333concat =
334 let unfIn = UF.replicateM 10
334 let unfIn = UF.replicateM 10
335 unfOut = UF.map return $ UF.enumerateFromToIntegral 10
335 unfOut = UF.map return $ UF.enumerateFromToIntegral 10
336− unf = UF.concat unfOut unfIn
336+ unf = UF.many unfOut unfIn
337 lst = Prelude.concat $ Prelude.map (Prelude.replicate 10) [1 .. 10]
337 lst = Prelude.concat $ Prelude.map (Prelude.replicate 10) [1 .. 10]
338 in testUnfoldD unf 1 lst
338 in testUnfoldD unf 1 lst
339
339