@@ -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