on master help sign in
Rename arraysOf to chunksOf
b5c7969Adithya Kumar
benchmark/Streamly/Benchmark/Data/Array/Stream.hs+2−2
@@ -295,8 +295,8 @@ main = do
295 then return (undefined, undefined)
295 then return (undefined, undefined)
296 else
296 else
297 do
297 do
298− small <- Stream.toList $ Stream.arraysOf 100 $ sourceUnfoldrM value 0
298+ small <- Stream.toList $ Stream.chunksOf 100 $ sourceUnfoldrM value 0
299− big <- Stream.toList $ Stream.arraysOf value $ sourceUnfoldrM value 0
299+ big <- Stream.toList $ Stream.chunksOf value $ sourceUnfoldrM value 0
300 return (small, big)
300 return (small, big)
301
301
302 allBenchmarks env arrays value =
302 allBenchmarks env arrays value =
benchmark/Streamly/Benchmark/Data/Parser.hs+1−1
@@ -853,7 +853,7 @@ main = do
853
853
854 where
854 where
855
855
856− alloc value = Stream.fold Fold.toList $ Stream.arraysOf 100 $ sourceUnfoldrM value 0
856+ alloc value = Stream.fold Fold.toList $ Stream.chunksOf 100 $ sourceUnfoldrM value 0
857
857
858 allBenchmarks env arrays value =
858 allBenchmarks env arrays value =
859 [ bgroup (o_1_space_prefix moduleName) (o_1_space_serial value)
859 [ bgroup (o_1_space_prefix moduleName) (o_1_space_serial value)
benchmark/Streamly/Benchmark/Data/Parser/ParserK.hs+1−1
@@ -65,7 +65,7 @@ benchIOSink value name f =
65 bench name $ nfIO $ randomRIO (1,1)
65 bench name $ nfIO $ randomRIO (1,1)
66 >>= f
66 >>= f
67 . StreamK.fromStream
67 . StreamK.fromStream
68− . Stream.arraysOf 4000
68+ . Stream.chunksOf 4000
69 . sourceUnfoldrM value
69 . sourceUnfoldrM value
70
70
71-------------------------------------------------------------------------------
71-------------------------------------------------------------------------------
benchmark/Streamly/Benchmark/Data/Stream/Reduce.hs+1−1
@@ -199,7 +199,7 @@ o_1_space_grouping value =
199 ,
199 ,
200#endif
200#endif
201 -- XXX parseMany/parseIterate benchmarks are in the Parser/ParserD
201 -- XXX parseMany/parseIterate benchmarks are in the Parser/ParserD
202− -- modules we can bring those here. arraysOf benchmarks are in
202+ -- modules we can bring those here. chunksOf benchmarks are in
203 -- Parser/ParserD/Array.Stream/FileSystem.Handle.
203 -- Parser/ParserD/Array.Stream/FileSystem.Handle.
204 benchIOSink value "foldMany" foldMany
204 benchIOSink value "foldMany" foldMany
205 , benchIOSink value "foldManyPost" foldManyPost
205 , benchIOSink value "foldManyPost" foldManyPost
benchmark/Streamly/Benchmark/FileSystem/Handle/Read.hs+11−11
@@ -247,10 +247,10 @@ inspect $ 'groupsOf `hasNoType` ''AT.ArrayUnsafe -- AT.writeNUnsafe
247inspect $ 'groupsOf `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
247inspect $ 'groupsOf `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
248#endif
248#endif
249
249
250−{-# INLINE arraysOf #-}
250+{-# INLINE chunksOf #-}
251−arraysOf :: Int -> Handle -> IO Int
251+chunksOf :: Int -> Handle -> IO Int
252−arraysOf n inh =
252+chunksOf n inh =
253− S.fold Fold.length $ Stream.arraysOf n (S.unfold FH.reader inh)
253+ S.fold Fold.length $ Stream.chunksOf n (S.unfold FH.reader inh)
254
254
255o_1_space_reduce_read_grouped :: BenchEnv -> [Benchmark]
255o_1_space_reduce_read_grouped :: BenchEnv -> [Benchmark]
256o_1_space_reduce_read_grouped env =
256o_1_space_reduce_read_grouped env =
@@ -288,13 +288,13 @@ o_1_space_reduce_read_grouped env =
288 , mkBench "S.groupsOf 1000" env $ \inh _ ->
288 , mkBench "S.groupsOf 1000" env $ \inh _ ->
289 groupsOf 1000 inh
289 groupsOf 1000 inh
290
290
291− -- arraysOf may use a different impl than groupsOf
291+ -- chunksOf may use a different impl than groupsOf
292− , mkBenchSmall "S.arraysOf 1" env $ \inh _ ->
292+ , mkBenchSmall "S.chunksOf 1" env $ \inh _ ->
293− arraysOf 1 inh
293+ chunksOf 1 inh
294− , mkBench "S.arraysOf 10" env $ \inh _ ->
294+ , mkBench "S.chunksOf 10" env $ \inh _ ->
295− arraysOf 10 inh
295+ chunksOf 10 inh
296− , mkBench "S.arraysOf 1000" env $ \inh _ ->
296+ , mkBench "S.chunksOf 1000" env $ \inh _ ->
297− arraysOf 1000 inh
297+ chunksOf 1000 inh
298 ]
298 ]
299 ]
299 ]
300
300
benchmark/Streamly/Benchmark/FileSystem/Handle/ReadWrite.hs+2−2
@@ -110,7 +110,7 @@ readFromBytesNull inh devNull = IFH.putBytes devNull $ S.unfold FH.reader inh
110inspect $ hasNoTypeClasses 'readFromBytesNull
110inspect $ hasNoTypeClasses 'readFromBytesNull
111inspect $ 'readFromBytesNull `hasNoType` ''Step
111inspect $ 'readFromBytesNull `hasNoType` ''Step
112inspect $ 'readFromBytesNull `hasNoType` ''MAS.SpliceState
112inspect $ 'readFromBytesNull `hasNoType` ''MAS.SpliceState
113−inspect $ 'readFromBytesNull `hasNoType` ''AT.ArrayUnsafe -- FH.fromBytes/S.arraysOf
113+inspect $ 'readFromBytesNull `hasNoType` ''AT.ArrayUnsafe -- FH.fromBytes/S.chunksOf
114inspect $ 'readFromBytesNull `hasNoType` ''D.FoldMany
114inspect $ 'readFromBytesNull `hasNoType` ''D.FoldMany
115#endif
115#endif
116
116
@@ -124,7 +124,7 @@ readWithFromBytesNull inh devNull =
124inspect $ hasNoTypeClasses 'readWithFromBytesNull
124inspect $ hasNoTypeClasses 'readWithFromBytesNull
125inspect $ 'readWithFromBytesNull `hasNoType` ''Step
125inspect $ 'readWithFromBytesNull `hasNoType` ''Step
126inspect $ 'readWithFromBytesNull `hasNoType` ''MAS.SpliceState
126inspect $ 'readWithFromBytesNull `hasNoType` ''MAS.SpliceState
127−inspect $ 'readWithFromBytesNull `hasNoType` ''AT.ArrayUnsafe -- FH.fromBytes/S.arraysOf
127+inspect $ 'readWithFromBytesNull `hasNoType` ''AT.ArrayUnsafe -- FH.fromBytes/S.chunksOf
128inspect $ 'readWithFromBytesNull `hasNoType` ''D.FoldMany
128inspect $ 'readWithFromBytesNull `hasNoType` ''D.FoldMany
129#endif
129#endif
130
130
core/src/Streamly/Data/Stream.hs+1−1
@@ -431,7 +431,7 @@ module Streamly.Data.Stream
431 -- * Repeated Fold
431 -- * Repeated Fold
432 , foldMany -- XXX Rename to foldRepeat
432 , foldMany -- XXX Rename to foldRepeat
433 , parseMany
433 , parseMany
434− , Array.arraysOf
434+ , Array.chunksOf
435
435
436 -- * Buffered Operations
436 -- * Buffered Operations
437 -- | Operations that require buffering of the stream.
437 -- | Operations that require buffering of the stream.
core/src/Streamly/Data/Stream/StreamDK.hs+1−1
@@ -436,7 +436,7 @@ module Streamly.Data.Stream.StreamDK
436 -- * Repeated Fold
436 -- * Repeated Fold
437 , foldMany -- XXX Rename to foldRepeat
437 , foldMany -- XXX Rename to foldRepeat
438 , parseMany
438 , parseMany
439− , arraysOf
439+ , chunksOf
440
440
441 -- * Buffered Operations
441 -- * Buffered Operations
442 -- | Operations that require buffering of the stream.
442 -- | Operations that require buffering of the stream.
core/src/Streamly/Internal/Data/Array.hs+1−1
@@ -175,7 +175,7 @@ fromStreamN n m = do
175-- as efficient when the size is already known.
175-- as efficient when the size is already known.
176--
176--
177-- Note that if the input stream is too large memory allocation for the array
177-- Note that if the input stream is too large memory allocation for the array
178−-- may fail. When the stream size is not known, `arraysOf` followed by
178+-- may fail. When the stream size is not known, `chunksOf` followed by
179-- processing of indvidual arrays in the resulting stream should be preferred.
179-- processing of indvidual arrays in the resulting stream should be preferred.
180--
180--
181-- /Pre-release/
181-- /Pre-release/
core/src/Streamly/Internal/Data/Array/Generic/Mut/Type.hs+1−1
@@ -126,7 +126,7 @@ module Streamly.Internal.Data.Array.Generic.Mut.Type
126 -- multidimensional array representations.
126 -- multidimensional array representations.
127
127
128 -- ** Construct from streams
128 -- ** Construct from streams
129− -- , arraysOf
129+ -- , chunksOf
130 -- , arrayStreamKFromStreamD
130 -- , arrayStreamKFromStreamD
131 -- , writeChunks
131 -- , writeChunks
132
132
core/src/Streamly/Internal/Data/Array/Mut.hs+1−1
@@ -90,7 +90,7 @@ getSlicesFromLen from len =
90-- as efficient when the size is already known.
90-- as efficient when the size is already known.
91--
91--
92-- Note that if the input stream is too large memory allocation for the array
92-- Note that if the input stream is too large memory allocation for the array
93−-- may fail. When the stream size is not known, `arraysOf` followed by
93+-- may fail. When the stream size is not known, `chunksOf` followed by
94-- processing of indvidual arrays in the resulting stream should be preferred.
94-- processing of indvidual arrays in the resulting stream should be preferred.
95--
95--
96-- /Pre-release/
96-- /Pre-release/
core/src/Streamly/Internal/Data/Array/Mut/Stream.hs+6−6
@@ -11,7 +11,7 @@
11module Streamly.Internal.Data.Array.Mut.Stream
11module Streamly.Internal.Data.Array.Mut.Stream
12 (
12 (
13 -- * Generation
13 -- * Generation
14− arraysOf
14+ chunksOf
15
15
16 -- * Compaction
16 -- * Compaction
17 , packArraysChunksOf
17 , packArraysChunksOf
@@ -43,18 +43,18 @@ import qualified Streamly.Internal.Data.Fold.Type as FL
43import qualified Streamly.Internal.Data.Stream.StreamD as D
43import qualified Streamly.Internal.Data.Stream.StreamD as D
44import qualified Streamly.Internal.Data.Parser.ParserD as ParserD
44import qualified Streamly.Internal.Data.Parser.ParserD as ParserD
45
45
46−-- | @arraysOf n stream@ groups the elements in the input stream into arrays of
46+-- | @chunksOf n stream@ groups the elements in the input stream into arrays of
47-- @n@ elements each.
47-- @n@ elements each.
48--
48--
49-- Same as the following but may be more efficient:
49-- Same as the following but may be more efficient:
50--
50--
51−-- > arraysOf n = Stream.foldMany (MArray.writeN n)
51+-- > chunksOf n = Stream.foldMany (MArray.writeN n)
52--
52--
53-- /Pre-release/
53-- /Pre-release/
54−{-# INLINE arraysOf #-}
54+{-# INLINE chunksOf #-}
55−arraysOf :: (MonadIO m, Unbox a)
55+chunksOf :: (MonadIO m, Unbox a)
56 => Int -> Stream m a -> Stream m (MutArray a)
56 => Int -> Stream m a -> Stream m (MutArray a)
57−arraysOf = MArray.arraysOf
57+chunksOf = MArray.chunksOf
58
58
59-------------------------------------------------------------------------------
59-------------------------------------------------------------------------------
60-- Compact
60-- Compact
core/src/Streamly/Internal/Data/Array/Mut/Type.hs+9−9
@@ -169,7 +169,7 @@ module Streamly.Internal.Data.Array.Mut.Type
169 -- multidimensional array representations.
169 -- multidimensional array representations.
170
170
171 -- ** Construct from streams
171 -- ** Construct from streams
172− , arraysOf
172+ , chunksOf
173 , arrayStreamKFromStreamD
173 , arrayStreamKFromStreamD
174 , writeChunks
174 , writeChunks
175
175
@@ -1285,20 +1285,20 @@ data GroupState s contents start end bound
1285 contents start end bound (GroupState s contents start end bound)
1285 contents start end bound (GroupState s contents start end bound)
1286 | GroupFinish
1286 | GroupFinish
1287
1287
1288−-- | @arraysOf n stream@ groups the input stream into a stream of
1288+-- | @chunksOf n stream@ groups the input stream into a stream of
1289-- arrays of size n.
1289-- arrays of size n.
1290--
1290--
1291−-- @arraysOf n = StreamD.foldMany (MutArray.writeN n)@
1291+-- @chunksOf n = StreamD.foldMany (MutArray.writeN n)@
1292--
1292--
1293-- /Pre-release/
1293-- /Pre-release/
1294−{-# INLINE_NORMAL arraysOf #-}
1294+{-# INLINE_NORMAL chunksOf #-}
1295−arraysOf :: forall m a. (MonadIO m, Unbox a)
1295+chunksOf :: forall m a. (MonadIO m, Unbox a)
1296 => Int -> D.Stream m a -> D.Stream m (MutArray a)
1296 => Int -> D.Stream m a -> D.Stream m (MutArray a)
1297-- XXX the idiomatic implementation leads to large regression in the D.reverse'
1297-- XXX the idiomatic implementation leads to large regression in the D.reverse'
1298-- benchmark. It seems it has difficulty producing optimized code when
1298-- benchmark. It seems it has difficulty producing optimized code when
1299-- converting to StreamK. Investigate GHC optimizations.
1299-- converting to StreamK. Investigate GHC optimizations.
1300−-- arraysOf n = D.foldMany (writeN n)
1300+-- chunksOf n = D.foldMany (writeN n)
1301−arraysOf n (D.Stream step state) =
1301+chunksOf n (D.Stream step state) =
1302 D.Stream step' (GroupStart state)
1302 D.Stream step' (GroupStart state)
1303
1303
1304 where
1304 where
@@ -1307,7 +1307,7 @@ arraysOf n (D.Stream step state) =
1307 step' _ (GroupStart st) = do
1307 step' _ (GroupStart st) = do
1308 when (n <= 0) $
1308 when (n <= 0) $
1309 -- XXX we can pass the module string from the higher level API
1309 -- XXX we can pass the module string from the higher level API
1310− error $ "Streamly.Internal.Data.MutArray.Mut.Type.arraysOf: "
1310+ error $ "Streamly.Internal.Data.MutArray.Mut.Type.chunksOf: "
1311 ++ "the size of arrays [" ++ show n
1311 ++ "the size of arrays [" ++ show n
1312 ++ "] must be a natural number"
1312 ++ "] must be a natural number"
1313 (MutArray contents start end bound :: MutArray a) <- liftIO $ newPinned n
1313 (MutArray contents start end bound :: MutArray a) <- liftIO $ newPinned n
@@ -1343,7 +1343,7 @@ arrayStreamKFromStreamD :: forall m a. (MonadIO m, Unbox a) =>
1343 D.Stream m a -> m (StreamK m (MutArray a))
1343 D.Stream m a -> m (StreamK m (MutArray a))
1344arrayStreamKFromStreamD =
1344arrayStreamKFromStreamD =
1345 let n = allocBytesToElemCount (undefined :: a) defaultChunkSize
1345 let n = allocBytesToElemCount (undefined :: a) defaultChunkSize
1346− in D.foldr K.cons K.nil . arraysOf n
1346+ in D.foldr K.cons K.nil . chunksOf n
1347
1347
1348-------------------------------------------------------------------------------
1348-------------------------------------------------------------------------------
1349-- Streams of arrays - Flattening
1349-- Streams of arrays - Flattening
core/src/Streamly/Internal/Data/Array/Type.hs+7−7
@@ -67,7 +67,7 @@ module Streamly.Internal.Data.Array.Type
67 , write
67 , write
68
68
69 -- * Streams of arrays
69 -- * Streams of arrays
70− , arraysOf
70+ , chunksOf
71 , bufferChunks
71 , bufferChunks
72 , flattenArrays
72 , flattenArrays
73 , flattenArraysRev
73 , flattenArraysRev
@@ -263,20 +263,20 @@ fromStreamD str = unsafeFreeze <$> MA.fromStreamD str
263{-# INLINE bufferChunks #-}
263{-# INLINE bufferChunks #-}
264bufferChunks :: (MonadIO m, Unbox a) =>
264bufferChunks :: (MonadIO m, Unbox a) =>
265 D.Stream m a -> m (K.StreamK m (Array a))
265 D.Stream m a -> m (K.StreamK m (Array a))
266−bufferChunks m = D.foldr K.cons K.nil $ arraysOf defaultChunkSize m
266+bufferChunks m = D.foldr K.cons K.nil $ chunksOf defaultChunkSize m
267
267
268−-- | @arraysOf n stream@ groups the elements in the input stream into arrays of
268+-- | @chunksOf n stream@ groups the elements in the input stream into arrays of
269-- @n@ elements each.
269-- @n@ elements each.
270--
270--
271-- Same as the following but may be more efficient:
271-- Same as the following but may be more efficient:
272--
272--
273−-- >>> arraysOf n = Stream.foldMany (Array.writeN n)
273+-- >>> chunksOf n = Stream.foldMany (Array.writeN n)
274--
274--
275-- /Pre-release/
275-- /Pre-release/
276−{-# INLINE_NORMAL arraysOf #-}
276+{-# INLINE_NORMAL chunksOf #-}
277−arraysOf :: forall m a. (MonadIO m, Unbox a)
277+chunksOf :: forall m a. (MonadIO m, Unbox a)
278 => Int -> D.Stream m a -> D.Stream m (Array a)
278 => Int -> D.Stream m a -> D.Stream m (Array a)
279−arraysOf n str = D.map unsafeFreeze $ MA.arraysOf n str
279+chunksOf n str = D.map unsafeFreeze $ MA.chunksOf n str
280
280
281-- | Use the "read" unfold instead.
281-- | Use the "read" unfold instead.
282--
282--
core/src/Streamly/Internal/Data/Fold/Chunked.hs+1−1
@@ -26,7 +26,7 @@
26-- >>> import qualified Streamly.Data.StreamK as StreamK
26-- >>> import qualified Streamly.Data.StreamK as StreamK
27--
27--
28-- >>> f = ChunkFold.fromFold (Fold.take 7 Fold.toList)
28-- >>> f = ChunkFold.fromFold (Fold.take 7 Fold.toList)
29−-- >>> s = Stream.arraysOf 5 $ Stream.fromList "hello world"
29+-- >>> s = Stream.chunksOf 5 $ Stream.fromList "hello world"
30-- >>> ArrayStream.runArrayFold f (StreamK.fromStream s)
30-- >>> ArrayStream.runArrayFold f (StreamK.fromStream s)
31-- Right "hello w"
31-- Right "hello w"
32--
32--
core/src/Streamly/Internal/Data/Stream/Bottom.hs+1−1
@@ -548,7 +548,7 @@ reverse' =
548 . D.fromStreamK
548 . D.fromStreamK
549 . K.reverse
549 . K.reverse
550 . D.toStreamK
550 . D.toStreamK
551− . A.arraysOf defaultChunkSize
551+ . A.chunksOf defaultChunkSize
552 . toStreamD
552 . toStreamD
553
553
554------------------------------------------------------------------------------
554------------------------------------------------------------------------------
core/src/Streamly/Internal/Data/Stream/Chunked.hs+6−6
@@ -11,7 +11,7 @@
11module Streamly.Internal.Data.Stream.Chunked
11module Streamly.Internal.Data.Stream.Chunked
12 (
12 (
13 -- * Creation
13 -- * Creation
14− arraysOf
14+ chunksOf
15
15
16 -- * Flattening to elements
16 -- * Flattening to elements
17 , concat
17 , concat
@@ -108,16 +108,16 @@ import qualified Streamly.Internal.Data.Stream.StreamK as K
108-- Generation
108-- Generation
109-------------------------------------------------------------------------------
109-------------------------------------------------------------------------------
110
110
111−-- | @arraysOf n stream@ groups the elements in the input stream into arrays of
111+-- | @chunksOf n stream@ groups the elements in the input stream into arrays of
112-- @n@ elements each.
112-- @n@ elements each.
113--
113--
114−-- > arraysOf n = Stream.groupsOf n (Array.writeN n)
114+-- > chunksOf n = Stream.groupsOf n (Array.writeN n)
115--
115--
116-- /Pre-release/
116-- /Pre-release/
117−{-# INLINE arraysOf #-}
117+{-# INLINE chunksOf #-}
118−arraysOf :: (MonadIO m, Unbox a)
118+chunksOf :: (MonadIO m, Unbox a)
119 => Int -> Stream m a -> Stream m (Array a)
119 => Int -> Stream m a -> Stream m (Array a)
120−arraysOf = A.arraysOf
120+chunksOf = A.chunksOf
121
121
122-------------------------------------------------------------------------------
122-------------------------------------------------------------------------------
123-- Append
123-- Append
core/src/Streamly/Internal/Data/Stream/Reduce.hs+6−6
@@ -37,7 +37,7 @@ module Streamly.Internal.Data.Stream.Reduce
37
37
38 -- ** Chunking
38 -- ** Chunking
39 -- | Element unaware grouping.
39 -- | Element unaware grouping.
40− , arraysOf
40+ , chunksOf
41
41
42 -- ** Splitting
42 -- ** Splitting
43 -- XXX Implement these as folds or parsers instead.
43 -- XXX Implement these as folds or parsers instead.
@@ -430,15 +430,15 @@ parseIterate f i m = fromStreamD $
430-- Chunking
430-- Chunking
431------------------------------------------------------------------------------
431------------------------------------------------------------------------------
432
432
433−-- | @arraysOf n stream@ groups the elements in the input stream into arrays of
433+-- | @chunksOf n stream@ groups the elements in the input stream into arrays of
434-- @n@ elements each.
434-- @n@ elements each.
435--
435--
436-- Same as the following but may be more efficient:
436-- Same as the following but may be more efficient:
437--
437--
438−-- >>> arraysOf n = Stream.foldMany (Array.writeN n)
438+-- >>> chunksOf n = Stream.foldMany (Array.writeN n)
439--
439--
440-- /Pre-release/
440-- /Pre-release/
441−{-# INLINE arraysOf #-}
441+{-# INLINE chunksOf #-}
442−arraysOf :: (MonadIO m, Unbox a)
442+chunksOf :: (MonadIO m, Unbox a)
443 => Int -> Stream m a -> Stream m (Array a)
443 => Int -> Stream m a -> Stream m (Array a)
444−arraysOf n = fromStreamD . Array.arraysOf n . toStreamD
444+chunksOf n = fromStreamD . Array.chunksOf n . toStreamD
core/src/Streamly/Internal/Data/Stream/StreamD/Transform.hs+1−1
@@ -1498,7 +1498,7 @@ reverseUnbox =
1498 . fromStreamK
1498 . fromStreamK
1499 . K.reverse
1499 . K.reverse
1500 . toStreamK
1500 . toStreamK
1501− . A.arraysOf defaultChunkSize
1501+ . A.chunksOf defaultChunkSize
1502
1502
1503-- | Buffer until the next element in sequence arrives. The function argument
1503-- | Buffer until the next element in sequence arrives. The function argument
1504-- determines the difference in sequence numbers. This could be useful in
1504-- determines the difference in sequence numbers. This could be useful in
core/src/Streamly/Internal/FileSystem/Dir.hs+2−2
@@ -397,8 +397,8 @@ fromChunksWithBufferOf n h xs = fromChunks h $ AS.compact n xs
397-- @since 0.7.0
397-- @since 0.7.0
398{-# INLINE fromStreamWithBufferOf #-}
398{-# INLINE fromStreamWithBufferOf #-}
399fromStreamWithBufferOf :: MonadIO m => Int -> Handle -> Stream m Word8 -> m ()
399fromStreamWithBufferOf :: MonadIO m => Int -> Handle -> Stream m Word8 -> m ()
400−fromStreamWithBufferOf n h m = fromChunks h $ S.arraysOf n m
400+fromStreamWithBufferOf n h m = fromChunks h $ S.chunksOf n m
401−-- fromStreamWithBufferOf n h m = fromChunks h $ AS.arraysOf n m
401+-- fromStreamWithBufferOf n h m = fromChunks h $ AS.chunksOf n m
402
402
403-- > write = 'writeWithBufferOf' A.defaultChunkSize
403-- > write = 'writeWithBufferOf' A.defaultChunkSize
404--
404--
core/src/Streamly/Internal/FileSystem/File.hs+2−2
@@ -405,7 +405,7 @@ fromChunks = fromChunksMode WriteMode
405{-# INLINE fromBytesWith #-}
405{-# INLINE fromBytesWith #-}
406fromBytesWith :: (MonadIO m, MonadCatch m)
406fromBytesWith :: (MonadIO m, MonadCatch m)
407 => Int -> FilePath -> Stream m Word8 -> m ()
407 => Int -> FilePath -> Stream m Word8 -> m ()
408−fromBytesWith n file xs = fromChunks file $ S.arraysOf n xs
408+fromBytesWith n file xs = fromChunks file $ S.chunksOf n xs
409
409
410{-# DEPRECATED fromBytesWithBufferOf "Please use 'fromBytesWith' instead" #-}
410{-# DEPRECATED fromBytesWithBufferOf "Please use 'fromBytesWith' instead" #-}
411{-# INLINE fromBytesWithBufferOf #-}
411{-# INLINE fromBytesWithBufferOf #-}
@@ -502,7 +502,7 @@ appendChunks = fromChunksMode AppendMode
502{-# INLINE appendWith #-}
502{-# INLINE appendWith #-}
503appendWith :: (MonadIO m, MonadCatch m)
503appendWith :: (MonadIO m, MonadCatch m)
504 => Int -> FilePath -> Stream m Word8 -> m ()
504 => Int -> FilePath -> Stream m Word8 -> m ()
505−appendWith n file xs = appendChunks file $ S.arraysOf n xs
505+appendWith n file xs = appendChunks file $ S.chunksOf n xs
506
506
507-- | Append a byte stream to a file. Combines the bytes in chunks of size up to
507-- | Append a byte stream to a file. Combines the bytes in chunks of size up to
508-- 'A.defaultChunkSize' before writing. If the file exists then the new data
508-- 'A.defaultChunkSize' before writing. If the file exists then the new data
core/src/Streamly/Internal/FileSystem/Handle.hs+3−5
@@ -429,13 +429,11 @@ putChunksWith n h xs = putChunks h $ AS.compact n xs
429-- in chunks of @bufsize@. A write is performed to the IO device as soon as we
429-- in chunks of @bufsize@. A write is performed to the IO device as soon as we
430-- collect the required input size.
430-- collect the required input size.
431--
431--
432−-- >>> putBytesWith n h m = Handle.putChunks h $ Stream.arraysOf n m
432+-- >>> putBytesWith n h m = Handle.putChunks h $ Stream.chunksOf n m
433--
433--
434{-# INLINE putBytesWith #-}
434{-# INLINE putBytesWith #-}
435putBytesWith :: MonadIO m => Int -> Handle -> Stream m Word8 -> m ()
435putBytesWith :: MonadIO m => Int -> Handle -> Stream m Word8 -> m ()
436−putBytesWith n h m = putChunks h $ A.arraysOf n m
436+putBytesWith n h m = putChunks h $ A.chunksOf n m
437−
438−-- putBytesWith n h m = putChunks h $ AS.arraysOf n m
439
437
440-- | Write a byte stream to a file handle. Accumulates the input in chunks of
438-- | Write a byte stream to a file handle. Accumulates the input in chunks of
441-- up to 'Streamly.Internal.Data.Array.Type.defaultChunkSize' before writing.
439-- up to 'Streamly.Internal.Data.Array.Type.defaultChunkSize' before writing.
@@ -494,7 +492,7 @@ writeChunksWithBufferOf = writeChunksWith
494-- do not want buffering to occur at GHC level as well. Same thing applies to
492-- do not want buffering to occur at GHC level as well. Same thing applies to
495-- writes as well.
493-- writes as well.
496
494
497−-- XXX Maybe we should have a Fold.arraysOf like we have Stream.arraysOf
495+-- XXX Maybe we should have a Fold.chunksOf like we have Stream.chunksOf
498
496
499-- | @writeWith reqSize handle@ writes the input stream to @handle@.
497-- | @writeWith reqSize handle@ writes the input stream to @handle@.
500-- Bytes in the input stream are collected into a buffer until we have a chunk
498-- Bytes in the input stream are collected into a buffer until we have a chunk
src/Streamly/Internal/Data/Stream/IsStream/Common.hs+1−1
@@ -533,7 +533,7 @@ reverse' =
533 . D.fromStreamK
533 . D.fromStreamK
534 . K.reverse
534 . K.reverse
535 . D.toStreamK
535 . D.toStreamK
536− . A.arraysOf defaultChunkSize
536+ . A.chunksOf defaultChunkSize
537 . toStreamD
537 . toStreamD
538
538
539------------------------------------------------------------------------------
539------------------------------------------------------------------------------
src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+2−2
@@ -185,7 +185,7 @@ import Streamly.Internal.Data.Unboxed (Unbox)
185import qualified Data.Heap as H
185import qualified Data.Heap as H
186import qualified Streamly.Internal.Data.Unfold as Unfold
186import qualified Streamly.Internal.Data.Unfold as Unfold
187import qualified Streamly.Internal.Data.Array.Type as A
187import qualified Streamly.Internal.Data.Array.Type as A
188− (arraysOf, read)
188+ (chunksOf, read)
189import qualified Streamly.Internal.Data.Fold as FL
189import qualified Streamly.Internal.Data.Fold as FL
190 (Fold, Step(..), takeEndBy_, takeEndBy, catMaybes, take)
190 (Fold, Step(..), takeEndBy_, takeEndBy, catMaybes, take)
191import qualified Streamly.Internal.Data.IsMap as IsMap
191import qualified Streamly.Internal.Data.IsMap as IsMap
@@ -996,7 +996,7 @@ chunksOf n f = fromStreamD . D.groupsOf n f . toStreamD
996{-# INLINE arraysOf #-}
996{-# INLINE arraysOf #-}
997arraysOf :: (IsStream t, MonadIO m, Unbox a)
997arraysOf :: (IsStream t, MonadIO m, Unbox a)
998 => Int -> t m a -> t m (Array a)
998 => Int -> t m a -> t m (Array a)
999−arraysOf n = fromStreamD . A.arraysOf n . toStreamD
999+arraysOf n = fromStreamD . A.chunksOf n . toStreamD
1000
1000
1001-- XXX we can implement this by repeatedly applying the 'lrunFor' fold.
1001-- XXX we can implement this by repeatedly applying the 'lrunFor' fold.
1002-- XXX add this example after fixing the serial stream rate control
1002-- XXX add this example after fixing the serial stream rate control
src/Streamly/Internal/FileSystem/FD.hs+1−1
@@ -410,7 +410,7 @@ _writevArraysPackedUpto n h xs =
410-- @since 0.7.0
410-- @since 0.7.0
411{-# INLINE writeInChunksOf #-}
411{-# INLINE writeInChunksOf #-}
412writeInChunksOf :: MonadIO m => Int -> Handle -> Stream m Word8 -> m ()
412writeInChunksOf :: MonadIO m => Int -> Handle -> Stream m Word8 -> m ()
413−writeInChunksOf n h m = writeArrays h $ AS.arraysOf n m
413+writeInChunksOf n h m = writeArrays h $ AS.chunksOf n m
414
414
415-- > write = 'writeInChunksOf' A.defaultChunkSize
415-- > write = 'writeInChunksOf' A.defaultChunkSize
416--
416--
src/Streamly/Internal/Network/Inet/TCP.hs+1−1
@@ -385,7 +385,7 @@ putBytesWithBufferOf
385 -> PortNumber
385 -> PortNumber
386 -> Stream m Word8
386 -> Stream m Word8
387 -> m ()
387 -> m ()
388−putBytesWithBufferOf n addr port m = putChunks addr port $ A.arraysOf n m
388+putBytesWithBufferOf n addr port m = putChunks addr port $ A.chunksOf n m
389
389
390-- | Like 'write' but provides control over the write buffer. Output will
390-- | Like 'write' but provides control over the write buffer. Output will
391-- be written to the IO device as soon as we collect the specified number of
391-- be written to the IO device as soon as we collect the specified number of
src/Streamly/Internal/Network/Socket.hs+2−2
@@ -97,7 +97,7 @@ import Streamly.Internal.System.IO (defaultChunkSize)
97import qualified Streamly.Data.Array as A (reader, length, writeN)
97import qualified Streamly.Data.Array as A (reader, length, writeN)
98import qualified Streamly.Data.Fold as FL
98import qualified Streamly.Data.Fold as FL
99import qualified Streamly.Internal.Data.Array.Type as A
99import qualified Streamly.Internal.Data.Array.Type as A
100− (unsafeFreeze, asPtrUnsafe, byteLength, writeNUnsafe, arraysOf)
100+ (unsafeFreeze, asPtrUnsafe, byteLength, writeNUnsafe, chunksOf)
101import qualified Streamly.Internal.Data.Array.Mut as MArray
101import qualified Streamly.Internal.Data.Array.Mut as MArray
102 (MutArray(..), newPinnedBytes, asPtrUnsafe)
102 (MutArray(..), newPinnedBytes, asPtrUnsafe)
103import qualified Streamly.Internal.Data.Stream.StreamD as S
103import qualified Streamly.Internal.Data.Stream.StreamD as S
@@ -495,7 +495,7 @@ writeChunksWithBufferOf = writeChunksWith
495--
495--
496{-# INLINE putBytesWith #-}
496{-# INLINE putBytesWith #-}
497putBytesWith :: MonadIO m => Int -> Socket -> Stream m Word8 -> m ()
497putBytesWith :: MonadIO m => Int -> Socket -> Stream m Word8 -> m ()
498−putBytesWith n h m = putChunks h $ A.arraysOf n m
498+putBytesWith n h m = putChunks h $ A.chunksOf n m
499
499
500-- | Write a byte stream to a socket. Accumulates the input in chunks of
500-- | Write a byte stream to a socket. Accumulates the input in chunks of
501-- specified number of bytes before writing.
501-- specified number of bytes before writing.
test/Streamly/Test/Data/Parser/ParserD.hs+1−1
@@ -659,7 +659,7 @@ parseUnfold = do
659 <*> chooseInt (1, len)
659 <*> chooseInt (1, len)
660 <*> chooseInt (1, len)) $ \(ls, clen, tlen) ->
660 <*> chooseInt (1, len)) $ \(ls, clen, tlen) ->
661 monadicIO $ do
661 monadicIO $ do
662− arrays <- toList $ S.arraysOf clen (S.fromList ls)
662+ arrays <- toList $ S.chunksOf clen (S.fromList ls)
663 let src = Source.source (Just (Producer.OuterLoop arrays))
663 let src = Source.source (Just (Producer.OuterLoop arrays))
664 let parser = P.fromFold (FL.take tlen FL.toList)
664 let parser = P.fromFold (FL.take tlen FL.toList)
665 let readSrc =
665 let readSrc =
test/Streamly/Test/Unicode/Stream.hs+1−1
@@ -67,7 +67,7 @@ propDecodeEncodeIdArrays :: Property
67propDecodeEncodeIdArrays =
67propDecodeEncodeIdArrays =
68 forAll genUnicode $ \list ->
68 forAll genUnicode $ \list ->
69 monadicIO $ do
69 monadicIO $ do
70− let wrds = Stream.arraysOf 8 $ SS.encodeUtf8' $ Stream.fromList list
70+ let wrds = Stream.chunksOf 8 $ SS.encodeUtf8' $ Stream.fromList list
71 chrs <- Stream.toList $ IUS.decodeUtf8Chunks wrds
71 chrs <- Stream.toList $ IUS.decodeUtf8Chunks wrds
72 assert (chrs == list)
72 assert (chrs == list)
73
73