@@ -234,18 +234,18 @@ module Streamly.Internal.Data.MutArray.Type
235 -- *** Concat
235 -- *** Concat
236 -- | Append the arrays in a stream to form a stream of elements.
236 -- | Append the arrays in a stream to form a stream of elements.
237− , concatChunks
237+ , concat
238− , concatChunksRev
238+ , concatRev
240 -- *** Compact
240 -- *** Compact
241 -- | Append the arrays in a stream to form a stream of larger arrays.
241 -- | Append the arrays in a stream to form a stream of larger arrays.
242 , SpliceState (..)
242 , SpliceState (..)
243− , pCompactChunksLE
243+ , pCompactLE
244− , rCompactChunksLE
244+ , rCompactLE
245− , fCompactChunksGE
245+ , fCompactGE
246− , lCompactChunksGE
246+ , lCompactGE
247− , compactChunksGE
247+ , compactGE
248− , compactChunksEQ
248+ , compactEQ
250 -- ** Utilities
250 -- ** Utilities
251 , roundUpToPower2
251 , roundUpToPower2
@@ -318,7 +318,7 @@ import qualified Streamly.Internal.Data.StreamK.Type as K
318import qualified Prelude
318import qualified Prelude
320import Prelude hiding
320import Prelude hiding
321− (Foldable(..), read, unlines, splitAt, reverse, truncate)
321+ (Foldable(..), concat, read, unlines, splitAt, reverse, truncate)
323#include "DocTestDataMutArray.hs"
323#include "DocTestDataMutArray.hs"
@@ -851,7 +851,7 @@ reallocWith label capSizer minIncrBytes arr = do
853 badSize newSize =
853 badSize newSize =
854− concat
854+ Prelude.concat
856 , ": new array size (in bytes) is less than required size "
856 , ": new array size (in bytes) is less than required size "
857 , show newSize
857 , show newSize
@@ -1465,14 +1465,14 @@ data FlattenState s contents a =
1466-- | Use the "reader" unfold instead.
1466-- | Use the "reader" unfold instead.
1468−-- @concatChunks = unfoldMany reader@
1468+-- @concat = unfoldMany reader@
1470-- We can try this if there are any fusion issues in the unfold.
1470-- We can try this if there are any fusion issues in the unfold.
1472−{-# INLINE_NORMAL concatChunks #-}
1472+{-# INLINE_NORMAL concat #-}
1473−concatChunks :: forall m a. (MonadIO m, Unbox a)
1473+concat :: forall m a. (MonadIO m, Unbox a)
1474 => D.Stream m (MutArray a) -> D.Stream m a
1474 => D.Stream m (MutArray a) -> D.Stream m a
1475−concatChunks (D.Stream step state) = D.Stream step' (OuterLoop state)
1475+concat (D.Stream step state) = D.Stream step' (OuterLoop state)
@@ -1495,18 +1495,18 @@ concatChunks (D.Stream step state) = D.Stream step' (OuterLoop state)
1495{-# DEPRECATED flattenArrays "Please use \"unfoldMany reader\" instead." #-}
1495{-# DEPRECATED flattenArrays "Please use \"unfoldMany reader\" instead." #-}
1496flattenArrays :: forall m a. (MonadIO m, Unbox a)
1496flattenArrays :: forall m a. (MonadIO m, Unbox a)
1497 => D.Stream m (MutArray a) -> D.Stream m a
1497 => D.Stream m (MutArray a) -> D.Stream m a
1498−flattenArrays = concatChunks
1498+flattenArrays = concat
1500-- | Use the "readerRev" unfold instead.
1500-- | Use the "readerRev" unfold instead.
1502−-- @concatChunks = unfoldMany readerRev@
1502+-- @concat = unfoldMany readerRev@
1504-- We can try this if there are any fusion issues in the unfold.
1504-- We can try this if there are any fusion issues in the unfold.
1506−{-# INLINE_NORMAL concatChunksRev #-}
1506+{-# INLINE_NORMAL concatRev #-}
1507−concatChunksRev :: forall m a. (MonadIO m, Unbox a)
1507+concatRev :: forall m a. (MonadIO m, Unbox a)
1508 => D.Stream m (MutArray a) -> D.Stream m a
1508 => D.Stream m (MutArray a) -> D.Stream m a
1509−concatChunksRev (D.Stream step state) = D.Stream step' (OuterLoop state)
1509+concatRev (D.Stream step state) = D.Stream step' (OuterLoop state)
@@ -1531,7 +1531,7 @@ concatChunksRev (D.Stream step state) = D.Stream step' (OuterLoop state)
1531{-# DEPRECATED flattenArraysRev "Please use \"unfoldMany readerRev\" instead." #-}
1531{-# DEPRECATED flattenArraysRev "Please use \"unfoldMany readerRev\" instead." #-}
1532flattenArraysRev :: forall m a. (MonadIO m, Unbox a)
1532flattenArraysRev :: forall m a. (MonadIO m, Unbox a)
1533 => D.Stream m (MutArray a) -> D.Stream m a
1533 => D.Stream m (MutArray a) -> D.Stream m a
1534−flattenArraysRev = concatChunksRev
1534+flattenArraysRev = concatRev
1536-------------------------------------------------------------------------------
1536-------------------------------------------------------------------------------
1537-- Unfolds
1537-- Unfolds
@@ -2625,21 +2625,21 @@ byteEq arr1 arr2 = fmap (EQ ==) $ byteCmp arr1 arr2
2625-- Compact
2625-- Compact
2626-------------------------------------------------------------------------------
2626-------------------------------------------------------------------------------
2628−-- | Parser @pCompactChunksLE n@ coalesces adjacent arrays in the input stream
2628+-- | Parser @pCompactLE n@ coalesces adjacent arrays in the input stream
2629-- only if the combined size would be less than or equal to n.
2629-- only if the combined size would be less than or equal to n.
2631-- /Internal/
2631-- /Internal/
2632−{-# INLINE_NORMAL pCompactChunksLE #-}
2632+{-# INLINE_NORMAL pCompactLE #-}
2633−pCompactChunksLE ::
2633+pCompactLE ::
2634 forall m a. (MonadIO m, Unbox a)
2634 forall m a. (MonadIO m, Unbox a)
2635 => Int -> Parser (MutArray a) m (MutArray a)
2635 => Int -> Parser (MutArray a) m (MutArray a)
2636−pCompactChunksLE n = Parser step initial extract
2636+pCompactLE n = Parser step initial extract
2640 nBytes = n * SIZE_OF(a)
2640 nBytes = n * SIZE_OF(a)
2642− functionName = "Streamly.Internal.Data.MutArray.pCompactChunksLE"
2642+ functionName = "Streamly.Internal.Data.MutArray.pCompactLE"
2644 initial =
2644 initial =
@@ -2683,19 +2683,19 @@ data SpliceState s arr
2683-- immutable array never has additional space so a new array is allocated
2683-- immutable array never has additional space so a new array is allocated
2684-- instead of mutating it.
2684-- instead of mutating it.
2686−-- | Scan @rCompactChunksLE n@ coalesces adjacent arrays in the input stream
2686+-- | Scan @rCompactLE n@ coalesces adjacent arrays in the input stream
2687-- only if the combined size would be less than or equal to n.
2687-- only if the combined size would be less than or equal to n.
2689-- /Internal/
2689-- /Internal/
2690−{-# INLINE_NORMAL rCompactChunksLE #-}
2690+{-# INLINE_NORMAL rCompactLE #-}
2691−rCompactChunksLE :: (MonadIO m, Unbox a)
2691+rCompactLE :: (MonadIO m, Unbox a)
2692 => Int -> D.Stream m (MutArray a) -> D.Stream m (MutArray a)
2692 => Int -> D.Stream m (MutArray a) -> D.Stream m (MutArray a)
2693−rCompactChunksLE n (D.Stream step state) =
2693+rCompactLE n (D.Stream step state) =
2694 D.Stream step' (SpliceInitial state)
2694 D.Stream step' (SpliceInitial state)
2698− functionName = "Streamly.Internal.Data.MutArray.rCompactChunksLE"
2698+ functionName = "Streamly.Internal.Data.MutArray.rCompactLE"
2700 {-# INLINE_LATE step' #-}
2700 {-# INLINE_LATE step' #-}
2701 step' gst (SpliceInitial st) = do
2701 step' gst (SpliceInitial st) = do
@@ -2735,20 +2735,20 @@ rCompactChunksLE n (D.Stream step state) =
2736 step' _ (SpliceYielding arr next) = return $ D.Yield arr next
2736 step' _ (SpliceYielding arr next) = return $ D.Yield arr next
2738−-- | Fold @fCompactChunksGE n@ coalesces adjacent arrays in the input stream
2738+-- | Fold @fCompactGE n@ coalesces adjacent arrays in the input stream
2739-- until the size becomes greater than or equal to n.
2739-- until the size becomes greater than or equal to n.
2741−{-# INLINE_NORMAL fCompactChunksGE #-}
2741+{-# INLINE_NORMAL fCompactGE #-}
2742−fCompactChunksGE ::
2742+fCompactGE ::
2743 forall m a. (MonadIO m, Unbox a)
2743 forall m a. (MonadIO m, Unbox a)
2744 => Int -> FL.Fold m (MutArray a) (MutArray a)
2744 => Int -> FL.Fold m (MutArray a) (MutArray a)
2745−fCompactChunksGE n = Fold step initial extract extract
2745+fCompactGE n = Fold step initial extract extract
2749 nBytes = n * SIZE_OF(a)
2749 nBytes = n * SIZE_OF(a)
2751− functionName = "Streamly.Internal.Data.MutArray.fCompactChunksGE"
2751+ functionName = "Streamly.Internal.Data.MutArray.fCompactGE"
2753 initial =
2753 initial =
@@ -2779,20 +2779,20 @@ fCompactChunksGE n = Fold step initial extract extract
2779 extract Nothing = return nil
2779 extract Nothing = return nil
2780 extract (Just buf) = return buf
2780 extract (Just buf) = return buf
2782−-- | Like 'compactChunksGE' but for transforming folds instead of stream.
2782+-- | Like 'compactGE' but for transforming folds instead of stream.
2784−-- >>> lCompactChunksGE n = Fold.many (MutArray.fCompactChunksGE n)
2784+-- >>> lCompactGE n = Fold.many (MutArray.fCompactGE n)
2786−{-# INLINE_NORMAL lCompactChunksGE #-}
2786+{-# INLINE_NORMAL lCompactGE #-}
2787−lCompactChunksGE :: (MonadIO m, Unbox a)
2787+lCompactGE :: (MonadIO m, Unbox a)
2788 => Int -> Fold m (MutArray a) () -> Fold m (MutArray a) ()
2788 => Int -> Fold m (MutArray a) () -> Fold m (MutArray a) ()
2789−-- lCompactChunksGE n = Fold.many (fCompactChunksGE n)
2789+-- lCompactGE n = Fold.many (fCompactGE n)
2790−lCompactChunksGE n (Fold step1 initial1 _ final1) =
2790+lCompactGE n (Fold step1 initial1 _ final1) =
2791 Fold step initial extract final
2791 Fold step initial extract final
2795− functionName = "Streamly.Internal.Data.MutArray.lCompactChunksGE"
2795+ functionName = "Streamly.Internal.Data.MutArray.lCompactGE"
2797 initial = do
2797 initial = do
2798 when (n <= 0) $
2798 when (n <= 0) $
@@ -2841,7 +2841,7 @@ lCompactChunksGE n (Fold step1 initial1 _ final1) =
2842 -- extract forces the pending buffer to be sent to the fold which is not
2842 -- extract forces the pending buffer to be sent to the fold which is not
2843 -- what we want.
2843 -- what we want.
2844− extract _ = error "lCompactChunksGE: not designed for scanning"
2844+ extract _ = error "lCompactGE: not designed for scanning"
2846 final (Tuple' Nothing r1) = final1 r1
2846 final (Tuple' Nothing r1) = final1 r1
2847 final (Tuple' (Just buf) r1) = do
2847 final (Tuple' (Just buf) r1) = do
@@ -2850,25 +2850,25 @@ lCompactChunksGE n (Fold step1 initial1 _ final1) =
2850 FL.Partial rr -> final1 rr
2850 FL.Partial rr -> final1 rr
2851 FL.Done _ -> return ()
2851 FL.Done _ -> return ()
2853−-- | @compactChunksGE n stream@ coalesces adjacent arrays in the @stream@ until
2853+-- | @compactGE n stream@ coalesces adjacent arrays in the @stream@ until
2854-- the size becomes greater than or equal to @n@.
2854-- the size becomes greater than or equal to @n@.
2856−-- >>> compactChunksGE n = Stream.foldMany (MutArray.fCompactChunksGE n)
2856+-- >>> compactGE n = Stream.foldMany (MutArray.fCompactGE n)
2858−{-# INLINE compactChunksGE #-}
2858+{-# INLINE compactGE #-}
2859−compactChunksGE ::
2859+compactGE ::
2860 (MonadIO m, Unbox a)
2860 (MonadIO m, Unbox a)
2861 => Int -> Stream m (MutArray a) -> Stream m (MutArray a)
2861 => Int -> Stream m (MutArray a) -> Stream m (MutArray a)
2862−compactChunksGE n = D.foldMany (fCompactChunksGE n)
2862+compactGE n = D.foldMany (fCompactGE n)
2864−-- | 'compactChunksEQ n' coalesces adajacent arrays in the input stream to
2864+-- | 'compactEQ n' coalesces adajacent arrays in the input stream to
2865-- arrays of exact size @n@.
2865-- arrays of exact size @n@.
2867-- /Unimplemented/
2867-- /Unimplemented/
2868−{-# INLINE compactChunksEQ #-}
2868+{-# INLINE compactEQ #-}
2869−compactChunksEQ :: -- (MonadIO m, Unbox a) =>
2869+compactEQ :: -- (MonadIO m, Unbox a) =>
2870 Int -> Stream m (MutArray a) -> Stream m (MutArray a)
2870 Int -> Stream m (MutArray a) -> Stream m (MutArray a)
2871−compactChunksEQ _n = undefined -- D.parseManyD (pCompactChunksEQ n)
2871+compactEQ _n = undefined -- D.parseManyD (pCompactEQ n)
2873-------------------------------------------------------------------------------
2873-------------------------------------------------------------------------------
2874-- In-place mutation algorithms
2874-- In-place mutation algorithms