@@ -169,7 +169,7 @@ module Streamly.Internal.Data.Array.Mut.Type
169 -- multidimensional array representations.
169 -- multidimensional array representations.
171 -- ** Construct from streams
171 -- ** Construct from streams
172− , arraysOf
172+ , chunksOf
173 , arrayStreamKFromStreamD
173 , arrayStreamKFromStreamD
174 , writeChunks
174 , writeChunks
@@ -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
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.
1291−-- @arraysOf n = StreamD.foldMany (MutArray.writeN n)@
1291+-- @chunksOf n = StreamD.foldMany (MutArray.writeN n)@
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)
@@ -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
1348-------------------------------------------------------------------------------
1348-------------------------------------------------------------------------------
1349-- Streams of arrays - Flattening
1349-- Streams of arrays - Flattening