@@ -197,11 +197,11 @@ module Streamly.Internal.Data.MutArray.Type
197 -- *** Construct from streams
197 -- *** Construct from streams
198 , chunksOf
198 , chunksOf
199 , pinnedChunksOf
199 , pinnedChunksOf
200− , writeChunks
200+ , buildChunks
202 -- *** Eliminate to streams
202 -- *** Eliminate to streams
203− , flattenArrays
203+ , concatChunks
204− , flattenArraysRev
204+ , concatChunksRev
206 -- *** Construct from arrays
206 -- *** Construct from arrays
207 -- get chunks without copying
207 -- get chunks without copying
@@ -230,6 +230,11 @@ module Streamly.Internal.Data.MutArray.Type
232 , c_memchr
232 , c_memchr
@@ -1418,14 +1423,14 @@ data FlattenState s contents a =
1419-- | Use the "reader" unfold instead.
1424-- | Use the "reader" unfold instead.
1421−-- @flattenArrays = unfoldMany reader@
1426+-- @concatChunks = unfoldMany reader@
1423-- We can try this if there are any fusion issues in the unfold.
1428-- We can try this if there are any fusion issues in the unfold.
1425−{-# INLINE_NORMAL flattenArrays #-}
1430+{-# INLINE_NORMAL concatChunks #-}
1426−flattenArrays :: forall m a. (MonadIO m, Unbox a)
1431+concatChunks :: forall m a. (MonadIO m, Unbox a)
1427 => D.Stream m (MutArray a) -> D.Stream m a
1432 => 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)
@@ -1445,16 +1450,21 @@ flattenArrays (D.Stream step state) = D.Stream step' (OuterLoop state)
1445 x <- liftIO $ peekAt p contents
1450 x <- liftIO $ peekAt p contents
1446 return $ D.Yield x (InnerLoop st contents (INDEX_NEXT(p,a)) end)
1451 return $ D.Yield x (InnerLoop st contents (INDEX_NEXT(p,a)) end)
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
1448-- | Use the "readerRev" unfold instead.
1458-- | Use the "readerRev" unfold instead.
1450−-- @flattenArrays = unfoldMany readerRev@
1460+-- @concatChunks = unfoldMany readerRev@
1452-- We can try this if there are any fusion issues in the unfold.
1462-- We can try this if there are any fusion issues in the unfold.
1454−{-# INLINE_NORMAL flattenArraysRev #-}
1464+{-# INLINE_NORMAL concatChunksRev #-}
1455−flattenArraysRev :: forall m a. (MonadIO m, Unbox a)
1465+concatChunksRev :: forall m a. (MonadIO m, Unbox a)
1456 => D.Stream m (MutArray a) -> D.Stream m a
1466 => 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)
@@ -1476,6 +1486,11 @@ flattenArraysRev (D.Stream step state) = D.Stream step' (OuterLoop state)
1476 let cur = INDEX_PREV(p,a)
1486 let cur = INDEX_PREV(p,a)
1477 return $ D.Yield x (InnerLoop st contents cur start)
1487 return $ D.Yield x (InnerLoop st contents cur start)
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
1479-------------------------------------------------------------------------------
1494-------------------------------------------------------------------------------
1480-- Unfolds
1495-- Unfolds
1481-------------------------------------------------------------------------------
1496-------------------------------------------------------------------------------
@@ -1915,7 +1930,7 @@ pinnedWriteNAligned align = writeNWith (pinnedNewAligned align)
1916-- | Buffer a stream into a stream of arrays.
1931-- | Buffer a stream into a stream of arrays.
1918−-- >>> writeChunks n = Fold.many (MutArray.writeN n) Fold.toStreamK
1933+-- >>> buildChunks n = Fold.many (MutArray.writeN n) Fold.toStreamK
1920-- Breaking an array into an array stream can be useful to consume a large
1935-- Breaking an array into an array stream can be useful to consume a large
1921-- array sequentially such that memory of the array is released incrementatlly.
1936-- array sequentially such that memory of the array is released incrementatlly.
@@ -1924,10 +1939,15 @@ pinnedWriteNAligned align = writeNWith (pinnedNewAligned align)
1925-- /Unimplemented/
1940-- /Unimplemented/
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
1947+{-# DEPRECATED writeChunks "Please use buildChunks instead." #-}
1928writeChunks :: (MonadIO m, Unbox a) =>
1948writeChunks :: (MonadIO m, Unbox a) =>
1929 Int -> Fold m a (StreamK n (MutArray a))
1949 Int -> Fold m a (StreamK n (MutArray a))
1930−writeChunks n = FL.many (writeN n) FL.toStreamK
1950+writeChunks = buildChunks
1932{-# INLINE_NORMAL writeWithAs #-}
1952{-# INLINE_NORMAL writeWithAs #-}
1933writeWithAs :: forall m a. (MonadIO m, Unbox a)
1953writeWithAs :: forall m a. (MonadIO m, Unbox a)
@@ -1953,7 +1973,7 @@ writeWithAs ps elemCount =
1953 extract = liftIO . rightSize
1973 extract = liftIO . rightSize
1955-- XXX Compare writeWith with fromStreamD which uses an array of streams
1975-- 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.
1957-- If writeWith is faster then we should use that to implement
1977-- If writeWith is faster then we should use that to implement
1958-- fromStreamD.
1978-- fromStreamD.
@@ -1977,7 +1997,7 @@ writeWithAs ps elemCount =
1978-- >>> f n = MutArray.writeAppendWith (* 2) (MutArray.new n)
1998-- >>> f n = MutArray.writeAppendWith (* 2) (MutArray.new n)
1979-- >>> writeWith n = Fold.rmapM MutArray.rightSize (f n)
1999-- >>> 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)
1982-- /Pre-release/
2002-- /Pre-release/
1983{-# INLINE_NORMAL writeWith #-}
2003{-# INLINE_NORMAL writeWith #-}