@@ -197,11 +197,11 @@ module Streamly.Internal.Data.MutArray.Type
197197 -- *** Construct from streams
198198 , chunksOf
199199 , pinnedChunksOf
200− , writeChunks
200+ , buildChunks
201201
202202 -- *** Eliminate to streams
203− , flattenArrays
204− , flattenArraysRev
203+ , concatChunks
204+ , concatChunksRev
205205
206206 -- *** Construct from arrays
207207 -- get chunks without copying
@@ -230,6 +230,11 @@ module Streamly.Internal.Data.MutArray.Type
230230 , memcpy
231231 , memcmp
232232 , c_memchr
233+
234+ -- * Deprecated
235+ , writeChunks
236+ , flattenArrays
237+ , flattenArraysRev
233238 )
234239where
235240
@@ -1418,14 +1423,14 @@ data FlattenState s contents a =
14181423
14191424-- | Use the "reader" unfold instead.
14201425--
1421−-- @flattenArrays = unfoldMany reader@
1426+-- @concatChunks = unfoldMany reader@
14221427--
14231428-- We can try this if there are any fusion issues in the unfold.
14241429--
1425−{-# INLINE_NORMAL flattenArrays #-}
1426−flattenArrays :: forall m a. (MonadIO m, Unbox a)
1430+{-# INLINE_NORMAL concatChunks #-}
1431+concatChunks :: forall m a. (MonadIO m, Unbox a)
14271432 => D.Stream m (MutArray a) -> D.Stream m a
1428−flattenArrays (D.Stream step state) = D.Stream step' (OuterLoop state)
1433+concatChunks (D.Stream step state) = D.Stream step' (OuterLoop state)
14291434
14301435 where
14311436
@@ -1445,16 +1450,21 @@ flattenArrays (D.Stream step state) = D.Stream step' (OuterLoop state)
14451450 x <- liftIO $ peekAt p contents
14461451 return $ D.Yield x (InnerLoop st contents (INDEX_NEXT(p,a)) end)
14471452
1453+{-# DEPRECATED flattenArrays "Please use \"unfoldMany reader\" instead." #-}
1454+flattenArrays :: forall m a. (MonadIO m, Unbox a)
1455+ => D.Stream m (MutArray a) -> D.Stream m a
1456+flattenArrays = concatChunks
1457+
14481458-- | Use the "readerRev" unfold instead.
14491459--
1450−-- @flattenArrays = unfoldMany readerRev@
1460+-- @concatChunks = unfoldMany readerRev@
14511461--
14521462-- We can try this if there are any fusion issues in the unfold.
14531463--
1454−{-# INLINE_NORMAL flattenArraysRev #-}
1455−flattenArraysRev :: forall m a. (MonadIO m, Unbox a)
1464+{-# INLINE_NORMAL concatChunksRev #-}
1465+concatChunksRev :: forall m a. (MonadIO m, Unbox a)
14561466 => D.Stream m (MutArray a) -> D.Stream m a
1457−flattenArraysRev (D.Stream step state) = D.Stream step' (OuterLoop state)
1467+concatChunksRev (D.Stream step state) = D.Stream step' (OuterLoop state)
14581468
14591469 where
14601470
@@ -1476,6 +1486,11 @@ flattenArraysRev (D.Stream step state) = D.Stream step' (OuterLoop state)
14761486 let cur = INDEX_PREV(p,a)
14771487 return $ D.Yield x (InnerLoop st contents cur start)
14781488
1489+{-# DEPRECATED flattenArraysRev "Please use \"unfoldMany readerRev\" instead." #-}
1490+flattenArraysRev :: forall m a. (MonadIO m, Unbox a)
1491+ => D.Stream m (MutArray a) -> D.Stream m a
1492+flattenArraysRev = concatChunksRev
1493+
14791494-------------------------------------------------------------------------------
14801495-- Unfolds
14811496-------------------------------------------------------------------------------
@@ -1915,7 +1930,7 @@ pinnedWriteNAligned align = writeNWith (pinnedNewAligned align)
19151930
19161931-- | Buffer a stream into a stream of arrays.
19171932--
1918−-- >>> writeChunks n = Fold.many (MutArray.writeN n) Fold.toStreamK
1933+-- >>> buildChunks n = Fold.many (MutArray.writeN n) Fold.toStreamK
19191934--
19201935-- Breaking an array into an array stream can be useful to consume a large
19211936-- array sequentially such that memory of the array is released incrementatlly.
@@ -1924,10 +1939,15 @@ pinnedWriteNAligned align = writeNWith (pinnedNewAligned align)
19241939--
19251940-- /Unimplemented/
19261941--
1927−{-# INLINE_NORMAL writeChunks #-}
1942+{-# INLINE_NORMAL buildChunks #-}
1943+buildChunks :: (MonadIO m, Unbox a) =>
1944+ Int -> Fold m a (StreamK n (MutArray a))
1945+buildChunks n = FL.many (writeN n) FL.toStreamK
1946+
1947+{-# DEPRECATED writeChunks "Please use buildChunks instead." #-}
19281948writeChunks :: (MonadIO m, Unbox a) =>
19291949 Int -> Fold m a (StreamK n (MutArray a))
1930−writeChunks n = FL.many (writeN n) FL.toStreamK
1950+writeChunks = buildChunks
19311951
19321952{-# INLINE_NORMAL writeWithAs #-}
19331953writeWithAs :: forall m a. (MonadIO m, Unbox a)
@@ -1953,7 +1973,7 @@ writeWithAs ps elemCount =
19531973 extract = liftIO . rightSize
19541974
19551975-- XXX Compare writeWith with fromStreamD which uses an array of streams
1956−-- implementation. We can write this using writeChunks above if that is faster.
1976+-- implementation. We can write this using buildChunks above if that is faster.
19571977-- If writeWith is faster then we should use that to implement
19581978-- fromStreamD.
19591979--
@@ -1977,7 +1997,7 @@ writeWithAs ps elemCount =
19771997--
19781998-- >>> f n = MutArray.writeAppendWith (* 2) (MutArray.new n)
19791999-- >>> writeWith n = Fold.rmapM MutArray.rightSize (f n)
1980−-- >>> writeWith n = Fold.rmapM MutArray.fromArrayStreamK (MutArray.writeChunks n)
2000+-- >>> writeWith n = Fold.rmapM MutArray.fromArrayStreamK (MutArray.buildChunks n)
19812001--
19822002-- /Pre-release/
19832003{-# INLINE_NORMAL writeWith #-}