on master help sign in
Rename arraysOf to chunksOf
commitb5c79693fbd1877d9e692e542ccf287bb0974578 authorAdithya Kumar <adithya@composewell.com> dateMon 6 Mar 2023, 15:47 (4 years ago) parentba0d42a
29 files changed+76−78
benchmark/Streamly/Benchmark/Data/Array/Stream.hs+2−2 benchmark/Streamly/Benchmark/Data/Parser.hs+1−1 benchmark/Streamly/Benchmark/Data/Parser/ParserK.hs+1−1 benchmark/Streamly/Benchmark/Data/Stream/Reduce.hs+1−1 benchmark/Streamly/Benchmark/FileSystem/Handle/Read.hs+11−11 benchmark/Streamly/Benchmark/FileSystem/Handle/ReadWrite.hs+2−2 core/src/Streamly/Data/Stream.hs+1−1 core/src/Streamly/Data/Stream/StreamDK.hs+1−1 core/src/Streamly/Internal/Data/Array.hs+1−1 core/src/Streamly/Internal/Data/Array/Generic/Mut/Type.hs+1−1 core/src/Streamly/Internal/Data/Array/Mut.hs+1−1 core/src/Streamly/Internal/Data/Array/Mut/Stream.hs+6−6 core/src/Streamly/Internal/Data/Array/Mut/Type.hs+9−9 core/src/Streamly/Internal/Data/Array/Type.hs+7−7 core/src/Streamly/Internal/Data/Fold/Chunked.hs+1−1 core/src/Streamly/Internal/Data/Stream/Bottom.hs+1−1 core/src/Streamly/Internal/Data/Stream/Chunked.hs+6−6 core/src/Streamly/Internal/Data/Stream/Reduce.hs+6−6 core/src/Streamly/Internal/Data/Stream/StreamD/Transform.hs+1−1 core/src/Streamly/Internal/FileSystem/Dir.hs+2−2 core/src/Streamly/Internal/FileSystem/File.hs+2−2 core/src/Streamly/Internal/FileSystem/Handle.hs+3−5 src/Streamly/Internal/Data/Stream/IsStream/Common.hs+1−1 src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+2−2 src/Streamly/Internal/FileSystem/FD.hs+1−1 src/Streamly/Internal/Network/Inet/TCP.hs+1−1 src/Streamly/Internal/Network/Socket.hs+2−2 test/Streamly/Test/Data/Parser/ParserD.hs+1−1 test/Streamly/Test/Unicode/Stream.hs+1−1
benchmark/Streamly/Benchmark/Data/Array/Stream.hs+2−2
@@ -295,8 +295,8 @@ main = do
295295 then return (undefined, undefined)
296296 else
297297 do
298− small <- Stream.toList $ Stream.arraysOf 100 $ sourceUnfoldrM value 0
299− big <- Stream.toList $ Stream.arraysOf value $ sourceUnfoldrM value 0
298+ small <- Stream.toList $ Stream.chunksOf 100 $ sourceUnfoldrM value 0
299+ big <- Stream.toList $ Stream.chunksOf value $ sourceUnfoldrM value 0
300300 return (small, big)
301301
302302 allBenchmarks env arrays value =
benchmark/Streamly/Benchmark/Data/Parser.hs+1−1
@@ -853,7 +853,7 @@ main = do
853853
854854 where
855855
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
857857
858858 allBenchmarks env arrays value =
859859 [ 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 =
6565 bench name $ nfIO $ randomRIO (1,1)
6666 >>= f
6767 . StreamK.fromStream
68− . Stream.arraysOf 4000
68+ . Stream.chunksOf 4000
6969 . sourceUnfoldrM value
7070
7171-------------------------------------------------------------------------------
benchmark/Streamly/Benchmark/Data/Stream/Reduce.hs+1−1
@@ -199,7 +199,7 @@ o_1_space_grouping value =
199199 ,
200200#endif
201201 -- 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
203203 -- Parser/ParserD/Array.Stream/FileSystem.Handle.
204204 benchIOSink value "foldMany" foldMany
205205 , benchIOSink value "foldManyPost" foldManyPost
benchmark/Streamly/Benchmark/FileSystem/Handle/Read.hs+11−11
@@ -247,10 +247,10 @@ inspect $ 'groupsOf `hasNoType` ''AT.ArrayUnsafe -- AT.writeNUnsafe
247247inspect $ 'groupsOf `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
248248#endif
249249
250−{-# INLINE arraysOf #-}
251−arraysOf :: Int -> Handle -> IO Int
252−arraysOf n inh =
253− S.fold Fold.length $ Stream.arraysOf n (S.unfold FH.reader inh)
250+{-# INLINE chunksOf #-}
251+chunksOf :: Int -> Handle -> IO Int
252+chunksOf n inh =
253+ S.fold Fold.length $ Stream.chunksOf n (S.unfold FH.reader inh)
254254
255255o_1_space_reduce_read_grouped :: BenchEnv -> [Benchmark]
256256o_1_space_reduce_read_grouped env =
@@ -288,13 +288,13 @@ o_1_space_reduce_read_grouped env =
288288 , mkBench "S.groupsOf 1000" env $ \inh _ ->
289289 groupsOf 1000 inh
290290
291− -- arraysOf may use a different impl than groupsOf
292− , mkBenchSmall "S.arraysOf 1" env $ \inh _ ->
293− arraysOf 1 inh
294− , mkBench "S.arraysOf 10" env $ \inh _ ->
295− arraysOf 10 inh
296− , mkBench "S.arraysOf 1000" env $ \inh _ ->
297− arraysOf 1000 inh
291+ -- chunksOf may use a different impl than groupsOf
292+ , mkBenchSmall "S.chunksOf 1" env $ \inh _ ->
293+ chunksOf 1 inh
294+ , mkBench "S.chunksOf 10" env $ \inh _ ->
295+ chunksOf 10 inh
296+ , mkBench "S.chunksOf 1000" env $ \inh _ ->
297+ chunksOf 1000 inh
298298 ]
299299 ]
300300
benchmark/Streamly/Benchmark/FileSystem/Handle/ReadWrite.hs+2−2
@@ -110,7 +110,7 @@ readFromBytesNull inh devNull = IFH.putBytes devNull $ S.unfold FH.reader inh
110110inspect $ hasNoTypeClasses 'readFromBytesNull
111111inspect $ 'readFromBytesNull `hasNoType` ''Step
112112inspect $ 'readFromBytesNull `hasNoType` ''MAS.SpliceState
113−inspect $ 'readFromBytesNull `hasNoType` ''AT.ArrayUnsafe -- FH.fromBytes/S.arraysOf
113+inspect $ 'readFromBytesNull `hasNoType` ''AT.ArrayUnsafe -- FH.fromBytes/S.chunksOf
114114inspect $ 'readFromBytesNull `hasNoType` ''D.FoldMany
115115#endif
116116
@@ -124,7 +124,7 @@ readWithFromBytesNull inh devNull =
124124inspect $ hasNoTypeClasses 'readWithFromBytesNull
125125inspect $ 'readWithFromBytesNull `hasNoType` ''Step
126126inspect $ 'readWithFromBytesNull `hasNoType` ''MAS.SpliceState
127−inspect $ 'readWithFromBytesNull `hasNoType` ''AT.ArrayUnsafe -- FH.fromBytes/S.arraysOf
127+inspect $ 'readWithFromBytesNull `hasNoType` ''AT.ArrayUnsafe -- FH.fromBytes/S.chunksOf
128128inspect $ 'readWithFromBytesNull `hasNoType` ''D.FoldMany
129129#endif
130130
core/src/Streamly/Data/Stream.hs+1−1
@@ -431,7 +431,7 @@ module Streamly.Data.Stream
431431 -- * Repeated Fold
432432 , foldMany -- XXX Rename to foldRepeat
433433 , parseMany
434− , Array.arraysOf
434+ , Array.chunksOf
435435
436436 -- * Buffered Operations
437437 -- | 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
436436 -- * Repeated Fold
437437 , foldMany -- XXX Rename to foldRepeat
438438 , parseMany
439− , arraysOf
439+ , chunksOf
440440
441441 -- * Buffered Operations
442442 -- | Operations that require buffering of the stream.
core/src/Streamly/Internal/Data/Array.hs+1−1
@@ -175,7 +175,7 @@ fromStreamN n m = do
175175-- as efficient when the size is already known.
176176--
177177-- 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
179179-- processing of indvidual arrays in the resulting stream should be preferred.
180180--
181181-- /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
126126 -- multidimensional array representations.
127127
128128 -- ** Construct from streams
129− -- , arraysOf
129+ -- , chunksOf
130130 -- , arrayStreamKFromStreamD
131131 -- , writeChunks
132132
core/src/Streamly/Internal/Data/Array/Mut.hs+1−1
@@ -90,7 +90,7 @@ getSlicesFromLen from len =
9090-- as efficient when the size is already known.
9191--
9292-- 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
9494-- processing of indvidual arrays in the resulting stream should be preferred.
9595--
9696-- /Pre-release/
core/src/Streamly/Internal/Data/Array/Mut/Stream.hs+6−6
@@ -11,7 +11,7 @@
1111module Streamly.Internal.Data.Array.Mut.Stream
1212 (
1313 -- * Generation
14− arraysOf
14+ chunksOf
1515
1616 -- * Compaction
1717 , packArraysChunksOf
@@ -43,18 +43,18 @@ import qualified Streamly.Internal.Data.Fold.Type as FL
4343import qualified Streamly.Internal.Data.Stream.StreamD as D
4444import qualified Streamly.Internal.Data.Parser.ParserD as ParserD
4545
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
4747-- @n@ elements each.
4848--
4949-- Same as the following but may be more efficient:
5050--
51−-- > arraysOf n = Stream.foldMany (MArray.writeN n)
51+-- > chunksOf n = Stream.foldMany (MArray.writeN n)
5252--
5353-- /Pre-release/
54−{-# INLINE arraysOf #-}
55−arraysOf :: (MonadIO m, Unbox a)
54+{-# INLINE chunksOf #-}
55+chunksOf :: (MonadIO m, Unbox a)
5656 => Int -> Stream m a -> Stream m (MutArray a)
57−arraysOf = MArray.arraysOf
57+chunksOf = MArray.chunksOf
5858
5959-------------------------------------------------------------------------------
6060-- Compact
core/src/Streamly/Internal/Data/Array/Mut/Type.hs+9−9
@@ -169,7 +169,7 @@ module Streamly.Internal.Data.Array.Mut.Type
169169 -- multidimensional array representations.
170170
171171 -- ** Construct from streams
172− , arraysOf
172+ , chunksOf
173173 , arrayStreamKFromStreamD
174174 , writeChunks
175175
@@ -1285,20 +1285,20 @@ data GroupState s contents start end bound
12851285 contents start end bound (GroupState s contents start end bound)
12861286 | GroupFinish
12871287
1288−-- | @arraysOf n stream@ groups the input stream into a stream of
1288+-- | @chunksOf n stream@ groups the input stream into a stream of
12891289-- arrays of size n.
12901290--
1291−-- @arraysOf n = StreamD.foldMany (MutArray.writeN n)@
1291+-- @chunksOf n = StreamD.foldMany (MutArray.writeN n)@
12921292--
12931293-- /Pre-release/
1294−{-# INLINE_NORMAL arraysOf #-}
1295−arraysOf :: forall m a. (MonadIO m, Unbox a)
1294+{-# INLINE_NORMAL chunksOf #-}
1295+chunksOf :: forall m a. (MonadIO m, Unbox a)
12961296 => Int -> D.Stream m a -> D.Stream m (MutArray a)
12971297-- XXX the idiomatic implementation leads to large regression in the D.reverse'
12981298-- benchmark. It seems it has difficulty producing optimized code when
12991299-- converting to StreamK. Investigate GHC optimizations.
1300−-- arraysOf n = D.foldMany (writeN n)
1301−arraysOf n (D.Stream step state) =
1300+-- chunksOf n = D.foldMany (writeN n)
1301+chunksOf n (D.Stream step state) =
13021302 D.Stream step' (GroupStart state)
13031303
13041304 where
@@ -1307,7 +1307,7 @@ arraysOf n (D.Stream step state) =
13071307 step' _ (GroupStart st) = do
13081308 when (n <= 0) $
13091309 -- 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: "
13111311 ++ "the size of arrays [" ++ show n
13121312 ++ "] must be a natural number"
13131313 (MutArray contents start end bound :: MutArray a) <- liftIO $ newPinned n
@@ -1343,7 +1343,7 @@ arrayStreamKFromStreamD :: forall m a. (MonadIO m, Unbox a) =>
13431343 D.Stream m a -> m (StreamK m (MutArray a))
13441344arrayStreamKFromStreamD =
13451345 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
13471347
13481348-------------------------------------------------------------------------------
13491349-- Streams of arrays - Flattening
core/src/Streamly/Internal/Data/Array/Type.hs+7−7
@@ -67,7 +67,7 @@ module Streamly.Internal.Data.Array.Type
6767 , write
6868
6969 -- * Streams of arrays
70− , arraysOf
70+ , chunksOf
7171 , bufferChunks
7272 , flattenArrays
7373 , flattenArraysRev
@@ -263,20 +263,20 @@ fromStreamD str = unsafeFreeze <$> MA.fromStreamD str
263263{-# INLINE bufferChunks #-}
264264bufferChunks :: (MonadIO m, Unbox a) =>
265265 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
267267
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
269269-- @n@ elements each.
270270--
271271-- Same as the following but may be more efficient:
272272--
273−-- >>> arraysOf n = Stream.foldMany (Array.writeN n)
273+-- >>> chunksOf n = Stream.foldMany (Array.writeN n)
274274--
275275-- /Pre-release/
276−{-# INLINE_NORMAL arraysOf #-}
277−arraysOf :: forall m a. (MonadIO m, Unbox a)
276+{-# INLINE_NORMAL chunksOf #-}
277+chunksOf :: forall m a. (MonadIO m, Unbox a)
278278 => 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
280280
281281-- | Use the "read" unfold instead.
282282--
core/src/Streamly/Internal/Data/Fold/Chunked.hs+1−1
@@ -26,7 +26,7 @@
2626-- >>> import qualified Streamly.Data.StreamK as StreamK
2727--
2828-- >>> 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"
3030-- >>> ArrayStream.runArrayFold f (StreamK.fromStream s)
3131-- Right "hello w"
3232--
core/src/Streamly/Internal/Data/Stream/Bottom.hs+1−1
@@ -548,7 +548,7 @@ reverse' =
548548 . D.fromStreamK
549549 . K.reverse
550550 . D.toStreamK
551− . A.arraysOf defaultChunkSize
551+ . A.chunksOf defaultChunkSize
552552 . toStreamD
553553
554554------------------------------------------------------------------------------
core/src/Streamly/Internal/Data/Stream/Chunked.hs+6−6
@@ -11,7 +11,7 @@
1111module Streamly.Internal.Data.Stream.Chunked
1212 (
1313 -- * Creation
14− arraysOf
14+ chunksOf
1515
1616 -- * Flattening to elements
1717 , concat
@@ -108,16 +108,16 @@ import qualified Streamly.Internal.Data.Stream.StreamK as K
108108-- Generation
109109-------------------------------------------------------------------------------
110110
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
112112-- @n@ elements each.
113113--
114−-- > arraysOf n = Stream.groupsOf n (Array.writeN n)
114+-- > chunksOf n = Stream.groupsOf n (Array.writeN n)
115115--
116116-- /Pre-release/
117−{-# INLINE arraysOf #-}
118−arraysOf :: (MonadIO m, Unbox a)
117+{-# INLINE chunksOf #-}
118+chunksOf :: (MonadIO m, Unbox a)
119119 => Int -> Stream m a -> Stream m (Array a)
120−arraysOf = A.arraysOf
120+chunksOf = A.chunksOf
121121
122122-------------------------------------------------------------------------------
123123-- Append
core/src/Streamly/Internal/Data/Stream/Reduce.hs+6−6
@@ -37,7 +37,7 @@ module Streamly.Internal.Data.Stream.Reduce
3737
3838 -- ** Chunking
3939 -- | Element unaware grouping.
40− , arraysOf
40+ , chunksOf
4141
4242 -- ** Splitting
4343 -- XXX Implement these as folds or parsers instead.
@@ -430,15 +430,15 @@ parseIterate f i m = fromStreamD $
430430-- Chunking
431431------------------------------------------------------------------------------
432432
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
434434-- @n@ elements each.
435435--
436436-- Same as the following but may be more efficient:
437437--
438−-- >>> arraysOf n = Stream.foldMany (Array.writeN n)
438+-- >>> chunksOf n = Stream.foldMany (Array.writeN n)
439439--
440440-- /Pre-release/
441−{-# INLINE arraysOf #-}
442−arraysOf :: (MonadIO m, Unbox a)
441+{-# INLINE chunksOf #-}
442+chunksOf :: (MonadIO m, Unbox a)
443443 => 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 =
14981498 . fromStreamK
14991499 . K.reverse
15001500 . toStreamK
1501− . A.arraysOf defaultChunkSize
1501+ . A.chunksOf defaultChunkSize
15021502
15031503-- | Buffer until the next element in sequence arrives. The function argument
15041504-- 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
397397-- @since 0.7.0
398398{-# INLINE fromStreamWithBufferOf #-}
399399fromStreamWithBufferOf :: MonadIO m => Int -> Handle -> Stream m Word8 -> m ()
400−fromStreamWithBufferOf n h m = fromChunks h $ S.arraysOf n m
401−-- fromStreamWithBufferOf n h m = fromChunks h $ AS.arraysOf n m
400+fromStreamWithBufferOf n h m = fromChunks h $ S.chunksOf n m
401+-- fromStreamWithBufferOf n h m = fromChunks h $ AS.chunksOf n m
402402
403403-- > write = 'writeWithBufferOf' A.defaultChunkSize
404404--
core/src/Streamly/Internal/FileSystem/File.hs+2−2
@@ -405,7 +405,7 @@ fromChunks = fromChunksMode WriteMode
405405{-# INLINE fromBytesWith #-}
406406fromBytesWith :: (MonadIO m, MonadCatch m)
407407 => 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
409409
410410{-# DEPRECATED fromBytesWithBufferOf "Please use 'fromBytesWith' instead" #-}
411411{-# INLINE fromBytesWithBufferOf #-}
@@ -502,7 +502,7 @@ appendChunks = fromChunksMode AppendMode
502502{-# INLINE appendWith #-}
503503appendWith :: (MonadIO m, MonadCatch m)
504504 => 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
506506
507507-- | Append a byte stream to a file. Combines the bytes in chunks of size up to
508508-- '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
429429-- in chunks of @bufsize@. A write is performed to the IO device as soon as we
430430-- collect the required input size.
431431--
432−-- >>> putBytesWith n h m = Handle.putChunks h $ Stream.arraysOf n m
432+-- >>> putBytesWith n h m = Handle.putChunks h $ Stream.chunksOf n m
433433--
434434{-# INLINE putBytesWith #-}
435435putBytesWith :: MonadIO m => Int -> Handle -> Stream m Word8 -> m ()
436−putBytesWith n h m = putChunks h $ A.arraysOf n m
437−
438−-- putBytesWith n h m = putChunks h $ AS.arraysOf n m
436+putBytesWith n h m = putChunks h $ A.chunksOf n m
439437
440438-- | Write a byte stream to a file handle. Accumulates the input in chunks of
441439-- up to 'Streamly.Internal.Data.Array.Type.defaultChunkSize' before writing.
@@ -494,7 +492,7 @@ writeChunksWithBufferOf = writeChunksWith
494492-- do not want buffering to occur at GHC level as well. Same thing applies to
495493-- writes as well.
496494
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
498496
499497-- | @writeWith reqSize handle@ writes the input stream to @handle@.
500498-- 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' =
533533 . D.fromStreamK
534534 . K.reverse
535535 . D.toStreamK
536− . A.arraysOf defaultChunkSize
536+ . A.chunksOf defaultChunkSize
537537 . toStreamD
538538
539539------------------------------------------------------------------------------
src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+2−2
@@ -185,7 +185,7 @@ import Streamly.Internal.Data.Unboxed (Unbox)
185185import qualified Data.Heap as H
186186import qualified Streamly.Internal.Data.Unfold as Unfold
187187import qualified Streamly.Internal.Data.Array.Type as A
188− (arraysOf, read)
188+ (chunksOf, read)
189189import qualified Streamly.Internal.Data.Fold as FL
190190 (Fold, Step(..), takeEndBy_, takeEndBy, catMaybes, take)
191191import qualified Streamly.Internal.Data.IsMap as IsMap
@@ -996,7 +996,7 @@ chunksOf n f = fromStreamD . D.groupsOf n f . toStreamD
996996{-# INLINE arraysOf #-}
997997arraysOf :: (IsStream t, MonadIO m, Unbox a)
998998 => Int -> t m a -> t m (Array a)
999−arraysOf n = fromStreamD . A.arraysOf n . toStreamD
999+arraysOf n = fromStreamD . A.chunksOf n . toStreamD
10001000
10011001-- XXX we can implement this by repeatedly applying the 'lrunFor' fold.
10021002-- 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 =
410410-- @since 0.7.0
411411{-# INLINE writeInChunksOf #-}
412412writeInChunksOf :: 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
414414
415415-- > write = 'writeInChunksOf' A.defaultChunkSize
416416--
src/Streamly/Internal/Network/Inet/TCP.hs+1−1
@@ -385,7 +385,7 @@ putBytesWithBufferOf
385385 -> PortNumber
386386 -> Stream m Word8
387387 -> 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
389389
390390-- | Like 'write' but provides control over the write buffer. Output will
391391-- 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)
9797import qualified Streamly.Data.Array as A (reader, length, writeN)
9898import qualified Streamly.Data.Fold as FL
9999import qualified Streamly.Internal.Data.Array.Type as A
100− (unsafeFreeze, asPtrUnsafe, byteLength, writeNUnsafe, arraysOf)
100+ (unsafeFreeze, asPtrUnsafe, byteLength, writeNUnsafe, chunksOf)
101101import qualified Streamly.Internal.Data.Array.Mut as MArray
102102 (MutArray(..), newPinnedBytes, asPtrUnsafe)
103103import qualified Streamly.Internal.Data.Stream.StreamD as S
@@ -495,7 +495,7 @@ writeChunksWithBufferOf = writeChunksWith
495495--
496496{-# INLINE putBytesWith #-}
497497putBytesWith :: 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
499499
500500-- | Write a byte stream to a socket. Accumulates the input in chunks of
501501-- specified number of bytes before writing.
test/Streamly/Test/Data/Parser/ParserD.hs+1−1
@@ -659,7 +659,7 @@ parseUnfold = do
659659 <*> chooseInt (1, len)
660660 <*> chooseInt (1, len)) $ \(ls, clen, tlen) ->
661661 monadicIO $ do
662− arrays <- toList $ S.arraysOf clen (S.fromList ls)
662+ arrays <- toList $ S.chunksOf clen (S.fromList ls)
663663 let src = Source.source (Just (Producer.OuterLoop arrays))
664664 let parser = P.fromFold (FL.take tlen FL.toList)
665665 let readSrc =
test/Streamly/Test/Unicode/Stream.hs+1−1
@@ -67,7 +67,7 @@ propDecodeEncodeIdArrays :: Property
6767propDecodeEncodeIdArrays =
6868 forAll genUnicode $ \list ->
6969 monadicIO $ do
70− let wrds = Stream.arraysOf 8 $ SS.encodeUtf8' $ Stream.fromList list
70+ let wrds = Stream.chunksOf 8 $ SS.encodeUtf8' $ Stream.fromList list
7171 chrs <- Stream.toList $ IUS.decodeUtf8Chunks wrds
7272 assert (chrs == list)
7373