@@ -88,10 +88,10 @@ module Streamly.Internal.Data.Array.Mut.Type
8888 , snocUnsafe
8989
9090 -- ** Appending streams
91− , appendNUnsafe
92− , appendN
93− , appendWith
94− , append
91+ , writeAppendNUnsafe
92+ , writeAppendN
93+ , writeAppendWith
94+ , writeAppend
9595
9696 -- * Eliminating and Reading
9797
@@ -1631,7 +1631,7 @@ foldr f z arr = D.foldr f z $ toStreamD arr
16311631
16321632-- XXX Keep the bound intact to not lose any free space? Perf impact?
16331633
1634−-- | @appendNUnsafe alloc n@ appends up to @n@ input items to the supplied
1634+-- | @writeAppendNUnsafe alloc n@ appends up to @n@ input items to the supplied
16351635-- array.
16361636--
16371637-- Unsafe: Do not drive the fold beyond @n@ elements, it will lead to memory
@@ -1640,12 +1640,12 @@ foldr f z arr = D.foldr f z $ toStreamD arr
16401640-- Any free space left in the array after appending @n@ elements is lost.
16411641--
16421642-- /Internal/
1643−{-# INLINE_NORMAL appendNUnsafe #-}
1644−appendNUnsafe :: forall m a. (MonadIO m, Unbox a) =>
1643+{-# INLINE_NORMAL writeAppendNUnsafe #-}
1644+writeAppendNUnsafe :: forall m a. (MonadIO m, Unbox a) =>
16451645 m (Array a)
16461646 -> Int
16471647 -> Fold m a (Array a)
1648−appendNUnsafe action n =
1648+writeAppendNUnsafe action n =
16491649 fmap fromArrayUnsafe $ FL.foldlM' step initial
16501650
16511651 where
@@ -1659,7 +1659,7 @@ appendNUnsafe action n =
16591659 -- otherwise we lose that space.
16601660 arr1 <-
16611661 if free < needed
1662− then noinline reallocWith "appendNUnsafeWith" (+ needed) needed arr
1662+ then noinline reallocWith "writeAppendNUnsafeWith" (+ needed) needed arr
16631663 else return arr
16641664 return $ toArrayUnsafe arr1
16651665
@@ -1670,27 +1670,27 @@ appendNUnsafe action n =
16701670-- | Append @n@ elements to an existing array. Any free space left in the array
16711671-- after appending @n@ elements is lost.
16721672--
1673−-- >>> appendN initial n = Fold.take n (Array.appendNUnsafe initial n)
1673+-- >>> writeAppendN initial n = Fold.take n (Array.writeAppendNUnsafe initial n)
16741674--
1675−{-# INLINE_NORMAL appendN #-}
1676−appendN :: forall m a. (MonadIO m, Unbox a) =>
1675+{-# INLINE_NORMAL writeAppendN #-}
1676+writeAppendN :: forall m a. (MonadIO m, Unbox a) =>
16771677 m (Array a) -> Int -> Fold m a (Array a)
1678−appendN initial n = FL.take n (appendNUnsafe initial n)
1678+writeAppendN initial n = FL.take n (writeAppendNUnsafe initial n)
16791679
1680−-- | @appendWith realloc action@ mutates the array generated by @action@ to
1680+-- | @writeAppendWith realloc action@ mutates the array generated by @action@ to
16811681-- append the input stream. If there is no reserved space available in the
16821682-- array it is reallocated to a size in bytes determined by @realloc oldSize@,
16831683-- where @oldSize@ is the current size of the array in bytes.
16841684--
16851685-- Note that the returned array may be a mutated version of original array.
16861686--
1687−-- >>> appendWith sizer = Fold.foldlM' (Array.snocWith sizer)
1687+-- >>> writeAppendWith sizer = Fold.foldlM' (Array.snocWith sizer)
16881688--
16891689-- /Pre-release/
1690−{-# INLINE appendWith #-}
1691−appendWith :: forall m a. (MonadIO m, Unbox a) =>
1690+{-# INLINE writeAppendWith #-}
1691+writeAppendWith :: forall m a. (MonadIO m, Unbox a) =>
16921692 (Int -> Int) -> m (Array a) -> Fold m a (Array a)
1693−appendWith sizer = FL.foldlM' (snocWith sizer)
1693+writeAppendWith sizer = FL.foldlM' (snocWith sizer)
16941694
16951695-- | @append action@ mutates the array generated by @action@ to append the
16961696-- input stream. If there is no reserved space available in the array it is
@@ -1698,12 +1698,12 @@ appendWith sizer = FL.foldlM' (snocWith sizer)
16981698--
16991699-- Note that the returned array may be a mutated version of original array.
17001700--
1701−-- >>> append = Array.appendWith (* 2)
1701+-- >>> writeAppend = Array.writeAppendWith (* 2)
17021702--
1703−{-# INLINE append #-}
1704−append :: forall m a. (MonadIO m, Unbox a) =>
1703+{-# INLINE writeAppend #-}
1704+writeAppend :: forall m a. (MonadIO m, Unbox a) =>
17051705 m (Array a) -> Fold m a (Array a)
1706−append = appendWith (* 2)
1706+writeAppend = writeAppendWith (* 2)
17071707
17081708-- XXX We can carry bound as well in the state to make sure we do not lose the
17091709-- remaining capacity. Need to check perf impact.
@@ -1711,7 +1711,7 @@ append = appendWith (* 2)
17111711-- | Like 'writeNUnsafe' but takes a new array allocator @alloc size@ function
17121712-- as argument.
17131713--
1714−-- >>> writeNWithUnsafe alloc n = Array.appendNUnsafe (alloc n) n
1714+-- >>> writeNWithUnsafe alloc n = Array.writeAppendNUnsafe (alloc n) n
17151715--
17161716-- /Pre-release/
17171717{-# INLINE_NORMAL writeNWithUnsafe #-}
@@ -1745,7 +1745,7 @@ writeNUnsafe = writeNWithUnsafe newPinned
17451745-- allocated using the @alloc@ function.
17461746--
17471747-- >>> writeNWith alloc n = Fold.take n (Array.writeNWithUnsafe alloc n)
1748−-- >>> writeNWith alloc n = Array.appendN (alloc n) n
1748+-- >>> writeNWith alloc n = Array.writeAppendN (alloc n) n
17491749--
17501750{-# INLINE_NORMAL writeNWith #-}
17511751writeNWith :: forall m a. (MonadIO m, Unbox a)
@@ -1757,7 +1757,7 @@ writeNWith alloc n = FL.take n (writeNWithUnsafe alloc n)
17571757--
17581758-- >>> writeN = Array.writeNWith Array.newPinned
17591759-- >>> writeN n = Fold.take n (Array.writeNUnsafe n)
1760−-- >>> writeN n = Array.appendN (Array.newPinned n) n
1760+-- >>> writeN n = Array.writeAppendN (Array.newPinned n) n
17611761--
17621762{-# INLINE_NORMAL writeN #-}
17631763writeN :: forall m a. (MonadIO m, Unbox a) => Int -> Fold m a (Array a)
@@ -1803,7 +1803,7 @@ writeRevN = writeRevNWith newPinned
18031803-- stream to an 'Array' aligned to the given size.
18041804--
18051805-- >>> writeNAligned align = Array.writeNWith (Array.newAlignedPinned align)
1806−-- >>> writeNAligned align n = Array.appendN (Array.newAlignedPinned align n) n
1806+-- >>> writeNAligned align n = Array.writeAppendN (Array.newAlignedPinned align n) n
18071807--
18081808-- /Pre-release/
18091809--
@@ -1853,7 +1853,7 @@ writeChunks n = FL.many (writeN n) FL.toStreamK
18531853--
18541854-- /Caution! Do not use this on infinite streams./
18551855--
1856−-- >>> f n = Array.appendWith (* 2) (Array.newPinned n)
1856+-- >>> f n = Array.writeAppendWith (* 2) (Array.newPinned n)
18571857-- >>> writeWith n = Fold.rmapM Array.rightSize (f n)
18581858-- >>> writeWith n = Fold.rmapM Array.fromArrayStreamK (Array.writeChunks n)
18591859--
@@ -1861,7 +1861,7 @@ writeChunks n = FL.many (writeN n) FL.toStreamK
18611861{-# INLINE_NORMAL writeWith #-}
18621862writeWith :: forall m a. (MonadIO m, Unbox a)
18631863 => Int -> Fold m a (Array a)
1864−-- writeWith n = FL.rmapM rightSize $ appendWith (* 2) (newPinned n)
1864+-- writeWith n = FL.rmapM rightSize $ writeAppendWith (* 2) (newPinned n)
18651865writeWith elemCount =
18661866 FL.rmapM extract $ FL.foldlM' step initial
18671867
@@ -2055,7 +2055,7 @@ spliceWith :: forall m a. (MonadIO m, Unbox a) =>
20552055 (Int -> Int -> Int) -> Array a -> Array a -> m (Array a)
20562056spliceWith sizer dst@(Array _ start end bound) src = do
20572057{-
2058− let f = appendWith (`sizer` byteLength src) (return dst)
2058+ let f = writeAppendWith (`sizer` byteLength src) (return dst)
20592059 in D.fold f (toStreamD src)
20602060-}
20612061 assert (end <= bound) (return ())