From eac92946572ade8c5ada938252224042aca8cf76 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Sat, 6 Jan 2024 16:06:54 +0530 Subject: [PATCH] Rename write* to create* in Array/Generic module --- core/src/Streamly/Data/Array/Generic.hs | 29 ++++++++++--------- .../Streamly/Internal/Data/Array/Generic.hs | 26 +++++++++++++---- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/core/src/Streamly/Data/Array/Generic.hs b/core/src/Streamly/Data/Array/Generic.hs index 7e33e5ce..0d70180f 100644 --- a/core/src/Streamly/Data/Array/Generic.hs +++ b/core/src/Streamly/Data/Array/Generic.hs @@ -15,34 +15,37 @@ module Streamly.Data.Array.Generic ( Array -- * Construction - , A.fromListN - , A.fromList + , fromListN + , fromList -- MonadicAPIs - , A.writeN - , A.write + , createOf + , create -- * Conversion - , A.toList + , toList -- * Streams - , A.read - , A.readRev + , read + , readRev -- * Unfolds - , A.reader + , reader -- , A.readerRev -- * Random Access - , A.length - , A.getIndex + , length + , getIndex -- -- * Folding Arrays -- , A.streamFold -- , A.fold + + -- * Deprecated + , writeN + , write ) where -import Streamly.Internal.Data.Array.Generic (Array) - -import qualified Streamly.Internal.Data.Array.Generic as A +import Streamly.Internal.Data.Array.Generic +import Prelude hiding (length, read) diff --git a/core/src/Streamly/Internal/Data/Array/Generic.hs b/core/src/Streamly/Internal/Data/Array/Generic.hs index 4a24906a..ab476d4b 100644 --- a/core/src/Streamly/Internal/Data/Array/Generic.hs +++ b/core/src/Streamly/Internal/Data/Array/Generic.hs @@ -11,8 +11,8 @@ module Streamly.Internal.Data.Array.Generic -- * Construction , nil - , writeN - , write + , createOf + , create , writeWith , writeLastN @@ -44,6 +44,10 @@ module Streamly.Internal.Data.Array.Generic , getIndex , getSliceUnsafe , strip + + -- * Deprecated + , writeN + , write ) where @@ -104,9 +108,15 @@ nil = unsafePerformIO $ unsafeFreeze <$> MArray.nil -- Construction - Folds ------------------------------------------------------------------------------- -{-# INLINE_NORMAL writeN #-} +{-# INLINE_NORMAL createOf #-} +createOf :: MonadIO m => Int -> Fold m a (Array a) +createOf = fmap unsafeFreeze <$> MArray.createOf + +-- XXX Deprecate in major +-- {-# DEPRECATED writeN "Please use createOf instead." #-} +{-# INLINE writeN #-} writeN :: MonadIO m => Int -> Fold m a (Array a) -writeN = fmap unsafeFreeze <$> MArray.createOf +writeN = createOf {-# INLINE_NORMAL writeWith #-} writeWith :: MonadIO m => Int -> Fold m a (Array a) @@ -116,9 +126,15 @@ writeWith elemCount = unsafeFreeze <$> MArray.createWith elemCount -- -- /Caution! Do not use this on infinite streams./ -- +{-# INLINE create #-} +create :: MonadIO m => Fold m a (Array a) +create = fmap unsafeFreeze MArray.create + +-- XXX Deprecate in major +-- {-# DEPRECATED write "Please use create instead." #-} {-# INLINE write #-} write :: MonadIO m => Fold m a (Array a) -write = fmap unsafeFreeze MArray.create +write = create fromPureStream :: Stream Identity a -> Array a fromPureStream x =