Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions core/src/Streamly/Internal/Data/MutArray/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -496,12 +496,12 @@ module Streamly.Internal.Data.MutArray.Type
, splitOn
, pinnedNewAligned
, unsafePinnedAsPtr
, grow -- XXX to be deprecated
, createWith -- XXX to be deprecated
, snocLinear -- XXX deprecate, replace by snocGrowBy or rename snoc1KB
, unsafeAppendN -- XXX deprecate, replaced by unsafeAppendMax
, appendN -- XXX deprecate, replaced by appendMax
, append -- XXX deprecate, replaced by append2
, grow
, createWith
, snocLinear
, unsafeAppendN
, appendN
, append
)
where

Expand Down Expand Up @@ -1151,8 +1151,7 @@ growTo nElems arr@MutArray{..} = do
then return arr
else realloc req arr

{-# INLINE grow #-}
grow = growTo
RENAME(grow,growTo)

-- | Like 'growTo' but specifies the required reserve (unused) capacity rather
-- than the total capacity. Increases the reserve capacity, if required, to at
Expand Down Expand Up @@ -1334,6 +1333,7 @@ snocWith sizer arr x = do
-- Performs O(n^2) copies to grow but is thrifty on memory.
--
-- /Pre-release/
{-# DEPRECATED snocLinear "Please use snocGrowBy instead. snocLinear ~ snocGrowBy (1024 / sizeOf (Proxy :: Proxy a) + 1)" #-}
{-# INLINE snocLinear #-}
snocLinear :: forall m a. (MonadIO m, Unbox a) => MutArray a -> a -> m (MutArray a)
snocLinear = snocWith (+ allocBytesToBytes (undefined :: a) arrayChunkBytes)
Expand Down Expand Up @@ -2351,6 +2351,7 @@ foldRev f arr = D.fold f (readRev arr)
-- Any free space left in the array after appending @n@ elements is lost.
--
-- /Internal/
{-# DEPRECATED unsafeAppendN "Please use unsafeAppendMax instead." #-}
{-# INLINE_NORMAL unsafeAppendN #-}
unsafeAppendN :: forall m a. (MonadIO m, Unbox a) =>
Int
Expand Down Expand Up @@ -2428,6 +2429,7 @@ writeAppendNUnsafe = unsafeAppendN
--
-- >>> appendN n initial = Fold.take n (MutArray.unsafeAppendN n initial)
--
{-# DEPRECATED appendN "Please use appendMax instead." #-}
{-# INLINE_NORMAL appendN #-}
appendN :: forall m a. (MonadIO m, Unbox a) =>
Int -> m (MutArray a) -> Fold m a (MutArray a)
Expand Down Expand Up @@ -2481,6 +2483,7 @@ writeAppendWith = appendWith
--
-- >>> append = Fold.foldlM' MutArray.snoc
--
{-# DEPRECATED append "Please use append2 instead." #-}
{-# INLINE append #-}
append :: forall m a. (MonadIO m, Unbox a) =>
m (MutArray a) -> Fold m a (MutArray a)
Expand Down Expand Up @@ -2824,7 +2827,7 @@ createMinOf, createWith :: forall m a. (MonadIO m, Unbox a)
-- createWith n = FL.rmapM rightSize $ appendWith (* 2) (emptyOf n)
createMinOf = writeWithAs Unpinned

createWith = createMinOf
RENAME(createWith,createMinOf)

{-# DEPRECATED writeWith "Please use createMinOf instead." #-}
{-# INLINE writeWith #-}
Expand Down
3 changes: 2 additions & 1 deletion test/Streamly/Test/Data/MutArray.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ testAppend =
where

action ls = do
arr0 <- MArray.emptyOf' 0
x <- Stream.fold
(MArray.append (MArray.emptyOf' 0))
(MArray.append2 arr0)
(Stream.fromList (ls::[Int]))
lst <- MArray.toList x
assert (ls == lst)
Expand Down
Loading