on master help sign in
Rename MutableByteArray to MutByteArray
commit47b10b39146d46a937cd0b086720638f9751005d authorHarendra Kumar <harendra@composewell.com> dateFri 24 Nov 2023, 08:06 (3 years ago) parent1b1008a
12 files changed+86−80
benchmark/Streamly/Benchmark/Data/Serialize.hs+3−3 core/src/Streamly/Data/Serialize.hs+1−1 core/src/Streamly/Internal/Data/Array/Type.hs+2−2 core/src/Streamly/Internal/Data/IORef/Unboxed.hs+2−2 core/src/Streamly/Internal/Data/MutArray/Type.hs+9−7 core/src/Streamly/Internal/Data/Serialize.hs+8−8 core/src/Streamly/Internal/Data/Serialize/TH/RecHeader.hs+3−3 core/src/Streamly/Internal/Data/Serialize/Type.hs+7−7 core/src/Streamly/Internal/Data/Unbox.hs+42−38 core/src/Streamly/Internal/Unicode/Stream.hs+4−4 test/Streamly/Test/Data/Serialize.hs+3−3 test/Streamly/Test/Data/Unbox.hs+2−2
benchmark/Streamly/Benchmark/Data/Serialize.hs+3−3
@@ -326,7 +326,7 @@ benchSink name times f = bench name (nfIO (randomRIO (times, times) >>= f))
326326
327327{-
328328{-# INLINE pokeWithSize #-}
329−pokeWithSize :: SERIALIZE_CLASS a => MutableByteArray -> a -> IO ()
329+pokeWithSize :: SERIALIZE_CLASS a => MutByteArray -> a -> IO ()
330330pokeWithSize arr val = do
331331 let n = getSize val
332332 n `seq` SERIALIZE_OP 0 arr val >> return ()
@@ -340,7 +340,7 @@ pokeTimesWithSize val times = do
340340-}
341341
342342{-# INLINE poke #-}
343−poke :: SERIALIZE_CLASS a => MutableByteArray -> a -> IO ()
343+poke :: SERIALIZE_CLASS a => MutByteArray -> a -> IO ()
344344poke arr val = SERIALIZE_OP 0 arr val >> return ()
345345
346346{-# INLINE pokeTimes #-}
@@ -363,7 +363,7 @@ encodeTimes val times = loop times encode val
363363
364364{-# INLINE peek #-}
365365peek :: forall a. (NFData a, SERIALIZE_CLASS a) =>
366− (a, Int) -> MutableByteArray -> IO ()
366+ (a, Int) -> MutByteArray -> IO ()
367367#ifdef USE_UNBOX
368368peek (_val, _) arr = do
369369 (val1 :: a) <- DESERIALIZE_OP 0 arr
core/src/Streamly/Data/Serialize.hs+1−1
@@ -42,7 +42,7 @@ module Streamly.Data.Serialize
4242 (
4343
4444 -- * MutableByteArray
45− MutableByteArray
45+ MutByteArray
4646 -- , isPinned
4747 -- , pin
4848 -- , unpin
core/src/Streamly/Internal/Data/Array/Type.hs+2−2
@@ -107,7 +107,7 @@ import GHC.Exts (IsList, IsString(..), Addr#)
107107
108108import GHC.IO (unsafePerformIO)
109109import GHC.Ptr (Ptr(..))
110−import Streamly.Internal.Data.MutArray.Type (MutArray(..), MutableByteArray)
110+import Streamly.Internal.Data.MutArray.Type (MutArray(..), MutByteArray)
111111import Streamly.Internal.Data.Fold.Type (Fold(..))
112112import Streamly.Internal.Data.Stream.Type (Stream)
113113import Streamly.Internal.Data.Unbox (Unbox(..))
@@ -164,7 +164,7 @@ data Array a =
164164#endif
165165 -- All offsets are in terms of bytes from the start of arraycontents
166166 Array
167− { arrContents :: {-# UNPACK #-} !MutableByteArray
167+ { arrContents :: {-# UNPACK #-} !MutByteArray
168168 , arrStart :: {-# UNPACK #-} !Int -- offset
169169 , arrEnd :: {-# UNPACK #-} !Int -- offset + len
170170 }
core/src/Streamly/Internal/Data/IORef/Unboxed.hs+2−2
@@ -41,7 +41,7 @@ where
4141import Data.Proxy (Proxy(..))
4242import Control.Monad.IO.Class (MonadIO(..))
4343import Streamly.Internal.Data.Unbox
44− ( MutableByteArray(..)
44+ ( MutByteArray(..)
4545 , Unbox(..)
4646 , newBytes
4747 , sizeOf
@@ -50,7 +50,7 @@ import Streamly.Internal.Data.Unbox
5050import qualified Streamly.Internal.Data.Stream.Type as D
5151
5252-- | An 'IORef' holds a single 'Unbox'-able value.
53−newtype IORef a = IORef MutableByteArray
53+newtype IORef a = IORef MutByteArray
5454
5555-- | Create a new 'IORef'.
5656--
core/src/Streamly/Internal/Data/MutArray/Type.hs+9−7
@@ -31,6 +31,7 @@ module Streamly.Internal.Data.MutArray.Type
3131 -- * Type
3232 -- $arrayNotes
3333 MutArray (..)
34+ , MutByteArray
3435 , MutableByteArray
3536 , pin
3637 , unpin
@@ -239,7 +240,8 @@ import Data.Word (Word8)
239240import Foreign.C.Types (CSize(..), CInt(..))
240241import Foreign.Ptr (plusPtr, minusPtr, nullPtr)
241242import Streamly.Internal.Data.Unbox
242− ( MutableByteArray(..)
243+ ( MutByteArray(..)
244+ , MutableByteArray
243245 , Unbox(..)
244246 , PinnedState(..)
245247 , getMutableByteArray#
@@ -343,7 +345,7 @@ data MutArray a =
343345 -- The array is a range into arrContents. arrContents may be a superset of
344346 -- the slice represented by the array. All offsets are in bytes.
345347 MutArray
346− { arrContents :: {-# UNPACK #-} !MutableByteArray
348+ { arrContents :: {-# UNPACK #-} !MutByteArray
347349 , arrStart :: {-# UNPACK #-} !Int -- ^ index into arrContents
348350 , arrEnd :: {-# UNPACK #-} !Int -- ^ index into arrContents
349351 -- Represents the first invalid index of
@@ -405,7 +407,7 @@ isPinned MutArray{..} = Unboxed.isPinned arrContents
405407-- /Pre-release/
406408{-# INLINE newArrayWith #-}
407409newArrayWith :: forall m a. (MonadIO m, Unbox a)
408− => (Int -> Int -> m MutableByteArray) -> Int -> Int -> m (MutArray a)
410+ => (Int -> Int -> m MutByteArray) -> Int -> Int -> m (MutArray a)
409411newArrayWith alloc alignSize count = do
410412 let size = max (count * SIZE_OF(a)) 0
411413 contents <- alloc size alignSize
@@ -602,7 +604,7 @@ modify MutArray{..} f = liftIO $
602604swapArrayByteIndices ::
603605 forall a. Unbox a
604606 => Proxy a
605− -> MutableByteArray
607+ -> MutByteArray
606608 -> Int
607609 -> Int
608610 -> IO ()
@@ -744,8 +746,8 @@ reallocExplicit elemSize newCapacityInBytes MutArray{..} = do
744746 if Unboxed.isPinned arrContents
745747 then Unboxed.pinnedNewBytes newCapMaxInBytes
746748 else Unboxed.newBytes newCapMaxInBytes
747− let !(MutableByteArray mbarrFrom#) = arrContents
748− !(MutableByteArray mbarrTo#) = contents
749+ let !(MutByteArray mbarrFrom#) = arrContents
750+ !(MutByteArray mbarrTo#) = contents
749751
750752 -- Copy old data
751753 let oldStart = arrStart
@@ -1455,7 +1457,7 @@ flattenArraysRev (D.Stream step state) = D.Stream step' (OuterLoop state)
14551457-------------------------------------------------------------------------------
14561458
14571459data ArrayUnsafe a = ArrayUnsafe
1458− {-# UNPACK #-} !MutableByteArray -- contents
1460+ {-# UNPACK #-} !MutByteArray -- contents
14591461 {-# UNPACK #-} !Int -- index 1
14601462 {-# UNPACK #-} !Int -- index 2
14611463
core/src/Streamly/Internal/Data/Serialize.hs+8−8
@@ -206,15 +206,15 @@ instance Serialize LiftedInteger where
206206liftInteger :: Integer -> LiftedInteger
207207liftInteger (IS x) = LIS (I# x)
208208liftInteger (IP x) =
209− LIP (Array (MutableByteArray (unsafeCoerce# x)) 0 (I# (sizeofByteArray# x)))
209+ LIP (Array (MutByteArray (unsafeCoerce# x)) 0 (I# (sizeofByteArray# x)))
210210liftInteger (IN x) =
211− LIN (Array (MutableByteArray (unsafeCoerce# x)) 0 (I# (sizeofByteArray# x)))
211+ LIN (Array (MutByteArray (unsafeCoerce# x)) 0 (I# (sizeofByteArray# x)))
212212
213213{-# INLINE unliftInteger #-}
214214unliftInteger :: LiftedInteger -> Integer
215215unliftInteger (LIS (I# x)) = IS x
216−unliftInteger (LIP (Array (MutableByteArray x) _ _)) = IP (unsafeCoerce# x)
217−unliftInteger (LIN (Array (MutableByteArray x) _ _)) = IN (unsafeCoerce# x)
216+unliftInteger (LIP (Array (MutByteArray x) _ _)) = IP (unsafeCoerce# x)
217+unliftInteger (LIN (Array (MutByteArray x) _ _)) = IN (unsafeCoerce# x)
218218
219219#else
220220
@@ -222,16 +222,16 @@ unliftInteger (LIN (Array (MutableByteArray x) _ _)) = IN (unsafeCoerce# x)
222222liftInteger :: Integer -> LiftedInteger
223223liftInteger (S# x) = LIS (I# x)
224224liftInteger (Jp# (BN# x)) =
225− LIP (Array (MutableByteArray (unsafeCoerce# x)) 0 (I# (sizeofByteArray# x)))
225+ LIP (Array (MutByteArray (unsafeCoerce# x)) 0 (I# (sizeofByteArray# x)))
226226liftInteger (Jn# (BN# x)) =
227− LIN (Array (MutableByteArray (unsafeCoerce# x)) 0 (I# (sizeofByteArray# x)))
227+ LIN (Array (MutByteArray (unsafeCoerce# x)) 0 (I# (sizeofByteArray# x)))
228228
229229{-# INLINE unliftInteger #-}
230230unliftInteger :: LiftedInteger -> Integer
231231unliftInteger (LIS (I# x)) = S# x
232−unliftInteger (LIP (Array (MutableByteArray x) _ _)) =
232+unliftInteger (LIP (Array (MutByteArray x) _ _)) =
233233 Jp# (BN# (unsafeCoerce# x))
234−unliftInteger (LIN (Array (MutableByteArray x) _ _)) =
234+unliftInteger (LIN (Array (MutByteArray x) _ _)) =
235235 Jn# (BN# (unsafeCoerce# x))
236236
237237#endif
core/src/Streamly/Internal/Data/Serialize/TH/RecHeader.hs+3−3
@@ -27,7 +27,7 @@ import Data.Maybe (fromJust)
2727import Language.Haskell.TH
2828import Streamly.Internal.Data.Serialize.Type (Serialize(..))
2929import Data.Foldable (foldlM)
30−import Streamly.Internal.Data.Unbox (MutableByteArray)
30+import Streamly.Internal.Data.Unbox (MutByteArray)
3131import Data.Proxy (Proxy(..))
3232
3333import qualified Streamly.Internal.Data.Unbox as Unbox
@@ -225,7 +225,7 @@ headerValue (SimpleDataCon _ fields) =
225225-- its type. We encode the size as 'Word32' hence there is a 4 bytes increase
226226-- in size.
227227{-# INLINE serializeWithSize #-}
228−serializeWithSize :: Serialize a => Int -> MutableByteArray -> a -> IO Int
228+serializeWithSize :: Serialize a => Int -> MutByteArray -> a -> IO Int
229229serializeWithSize off arr val = do
230230 off1 <- serialize (off + 4) arr val
231231 Unbox.pokeByteIndex off arr (int_w32 (off1 - off - 4) :: Word32)
@@ -263,7 +263,7 @@ mkRecSerializeExpr initialOffset (con@(SimpleDataCon cname fields)) = do
263263
264264{-# INLINE deserializeWithSize #-}
265265deserializeWithSize ::
266− Serialize a => Int -> MutableByteArray -> Int -> IO (Int, a)
266+ Serialize a => Int -> MutByteArray -> Int -> IO (Int, a)
267267deserializeWithSize off arr endOff = deserialize (off + 4) arr endOff
268268
269269conUpdateFuncDec :: Name -> [Field] -> Q [Dec]
core/src/Streamly/Internal/Data/Serialize/Type.hs+7−7
@@ -28,7 +28,7 @@ import Control.Exception (assert)
2828import Data.List (foldl')
2929import Data.Proxy (Proxy (..))
3030import Streamly.Internal.Data.Unbox
31− ( MutableByteArray(..)
31+ ( MutByteArray(..)
3232 , PinnedState(..)
3333 , Unbox
3434 )
@@ -144,7 +144,7 @@ class Serialize a where
144144 -- byte-offset and the deserialized value.
145145 --
146146 -- Throws an exception if the operation would exceed the supplied arrayLen.
147− deserialize :: Int -> MutableByteArray -> Int -> IO (Int, a)
147+ deserialize :: Int -> MutByteArray -> Int -> IO (Int, a)
148148
149149 -- | @serialize byte-offset array value@ writes the serialized
150150 -- representation of the @value@ in the array at the given byte-offset.
@@ -153,7 +153,7 @@ class Serialize a where
153153 -- This is an unsafe operation, the programmer must ensure that the array
154154 -- has enough space available to serialize the value as determined by the
155155 -- @size@ operation.
156− serialize :: Int -> MutableByteArray -> a -> IO Int
156+ serialize :: Int -> MutByteArray -> a -> IO Int
157157
158158--------------------------------------------------------------------------------
159159-- Instances
@@ -165,7 +165,7 @@ class Serialize a where
165165--
166166#ifdef DEBUG
167167{-# INLINE checkBounds #-}
168−checkBounds :: String -> Int -> MutableByteArray -> IO ()
168+checkBounds :: String -> Int -> MutByteArray -> IO ()
169169checkBounds _label _off _arr = do
170170 sz <- sizeOfMutableByteArray _arr
171171 if (_off > sz)
@@ -196,7 +196,7 @@ checkBounds _label _off _arr = do
196196-- serialized value with a size header.
197197--
198198{-# INLINE deserializeUnsafe #-}
199−deserializeUnsafe :: forall a. Unbox a => Int -> MutableByteArray -> Int -> IO (Int, a)
199+deserializeUnsafe :: forall a. Unbox a => Int -> MutByteArray -> Int -> IO (Int, a)
200200deserializeUnsafe off arr sz =
201201 let next = off + Unbox.sizeOf (Proxy :: Proxy a)
202202 in do
@@ -209,7 +209,7 @@ deserializeUnsafe off arr sz =
209209 ++ " max valid offset = " ++ show (sz - 1)
210210
211211{-# INLINE serializeUnsafe #-}
212−serializeUnsafe :: forall a. Unbox a => Int -> MutableByteArray -> a -> IO Int
212+serializeUnsafe :: forall a. Unbox a => Int -> MutByteArray -> a -> IO Int
213213serializeUnsafe off arr val =
214214 let next = off + Unbox.sizeOf (Proxy :: Proxy a)
215215 in do
@@ -227,7 +227,7 @@ instance Serialize _type where \
227227; deserialize off arr end = deserializeUnsafe off arr end :: IO (Int, _type) \
228228; {-# INLINE serialize #-} \
229229; serialize = \
230− serializeUnsafe :: Int -> MutableByteArray -> _type -> IO Int
230+ serializeUnsafe :: Int -> MutByteArray -> _type -> IO Int
231231
232232DERIVE_SERIALIZE_FROM_UNBOX(())
233233DERIVE_SERIALIZE_FROM_UNBOX(Bool)
core/src/Streamly/Internal/Data/Unbox.hs+42−38
@@ -13,8 +13,9 @@
1313--
1414module Streamly.Internal.Data.Unbox
1515 (
16− -- ** MutableByteArray
17− MutableByteArray(..)
16+ -- ** MutByteArray
17+ MutByteArray(..)
18+ , MutableByteArray
1819 , getMutableByteArray#
1920 , sizeOfMutableByteArray
2021 , nil
@@ -100,23 +101,26 @@ data PinnedState
100101-- | A lifted mutable byte array type wrapping @MutableByteArray# RealWorld@.
101102-- This is a low level array used to back high level unboxed arrays and
102103-- serialized data.
103−data MutableByteArray = MutableByteArray (MutableByteArray# RealWorld)
104+data MutByteArray = MutByteArray (MutableByteArray# RealWorld)
105+
106+{-# DEPRECATED MutableByteArray "Please use MutByteArray instead" #-}
107+type MutableByteArray = MutByteArray
104108
105109{-# INLINE getMutableByteArray# #-}
106−getMutableByteArray# :: MutableByteArray -> MutableByteArray# RealWorld
107−getMutableByteArray# (MutableByteArray mbarr) = mbarr
110+getMutableByteArray# :: MutByteArray -> MutableByteArray# RealWorld
111+getMutableByteArray# (MutByteArray mbarr) = mbarr
108112
109113-- | Return the size of the array in bytes.
110114{-# INLINE sizeOfMutableByteArray #-}
111−sizeOfMutableByteArray :: MutableByteArray -> IO Int
112−sizeOfMutableByteArray (MutableByteArray arr) =
115+sizeOfMutableByteArray :: MutByteArray -> IO Int
116+sizeOfMutableByteArray (MutByteArray arr) =
113117 IO $ \s ->
114118 case getSizeofMutableByteArray# arr s of
115119 (# s1, i #) -> (# s1, I# i #)
116120
117121{-# INLINE touch #-}
118−touch :: MutableByteArray -> IO ()
119−touch (MutableByteArray contents) =
122+touch :: MutByteArray -> IO ()
123+touch (MutByteArray contents) =
120124 IO $ \s -> case touch# contents s of s' -> (# s', () #)
121125
122126-- XXX We can provide another API for "unsafe" FFI calls passing an unlifted
@@ -131,7 +135,7 @@ touch (MutableByteArray contents) =
131135-- guarantees that unsafe calls will be performed in the calling thread. Making
132136-- it safe to pass heap-allocated objects to unsafe functions.
133137
134−-- | Use a @MutableByteArray@ as @Ptr a@. This is useful when we want to pass
138+-- | Use a @MutByteArray@ as @Ptr a@. This is useful when we want to pass
135139-- an array as a pointer to some operating system call or to a "safe" FFI call.
136140--
137141-- If the array is not pinned it is copied to pinned memory before passing it
@@ -148,7 +152,7 @@ touch (MutableByteArray contents) =
148152-- /Pre-release/
149153--
150154{-# INLINE asPtrUnsafe #-}
151−asPtrUnsafe :: MonadIO m => MutableByteArray -> (Ptr a -> m b) -> m b
155+asPtrUnsafe :: MonadIO m => MutByteArray -> (Ptr a -> m b) -> m b
152156asPtrUnsafe arr f = do
153157 contents <- liftIO $ pin arr
154158 let !ptr = Ptr (byteArrayContents#
@@ -162,41 +166,41 @@ asPtrUnsafe arr f = do
162166--------------------------------------------------------------------------------
163167
164168{-# NOINLINE nil #-}
165−nil :: MutableByteArray
169+nil :: MutByteArray
166170nil = unsafePerformIO $ newBytes 0
167171
168172{-# INLINE newBytes #-}
169−newBytes :: Int -> IO MutableByteArray
173+newBytes :: Int -> IO MutByteArray
170174newBytes nbytes | nbytes < 0 =
171175 errorWithoutStackTrace "newBytes: size must be >= 0"
172176newBytes (I# nbytes) = IO $ \s ->
173177 case newByteArray# nbytes s of
174178 (# s', mbarr# #) ->
175− let c = MutableByteArray mbarr#
179+ let c = MutByteArray mbarr#
176180 in (# s', c #)
177181
178182{-# INLINE pinnedNewBytes #-}
179−pinnedNewBytes :: Int -> IO MutableByteArray
183+pinnedNewBytes :: Int -> IO MutByteArray
180184pinnedNewBytes nbytes | nbytes < 0 =
181185 errorWithoutStackTrace "pinnedNewBytes: size must be >= 0"
182186pinnedNewBytes (I# nbytes) = IO $ \s ->
183187 case newPinnedByteArray# nbytes s of
184188 (# s', mbarr# #) ->
185− let c = MutableByteArray mbarr#
189+ let c = MutByteArray mbarr#
186190 in (# s', c #)
187191
188192{-# INLINE pinnedNewAlignedBytes #-}
189−pinnedNewAlignedBytes :: Int -> Int -> IO MutableByteArray
193+pinnedNewAlignedBytes :: Int -> Int -> IO MutByteArray
190194pinnedNewAlignedBytes nbytes _align | nbytes < 0 =
191195 errorWithoutStackTrace "pinnedNewAlignedBytes: size must be >= 0"
192196pinnedNewAlignedBytes (I# nbytes) (I# align) = IO $ \s ->
193197 case newAlignedPinnedByteArray# nbytes align s of
194198 (# s', mbarr# #) ->
195− let c = MutableByteArray mbarr#
199+ let c = MutByteArray mbarr#
196200 in (# s', c #)
197201
198202{-# INLINE newBytesAs #-}
199−newBytesAs :: PinnedState -> Int -> IO MutableByteArray
203+newBytesAs :: PinnedState -> Int -> IO MutByteArray
200204newBytesAs Unpinned = newBytes
201205newBytesAs Pinned = pinnedNewBytes
202206
@@ -209,9 +213,9 @@ newBytesAs Pinned = pinnedNewBytes
209213{-# INLINE putSliceUnsafe #-}
210214putSliceUnsafe ::
211215 MonadIO m
212− => MutableByteArray
216+ => MutByteArray
213217 -> Int
214− -> MutableByteArray
218+ -> MutByteArray
215219 -> Int
216220 -> Int
217221 -> m ()
@@ -236,8 +240,8 @@ putSliceUnsafe src srcStartBytes dst dstStartBytes lenBytes = liftIO $ do
236240-------------------------------------------------------------------------------
237241
238242{-# INLINE isPinned #-}
239−isPinned :: MutableByteArray -> Bool
240−isPinned (MutableByteArray arr#) =
243+isPinned :: MutByteArray -> Bool
244+isPinned (MutByteArray arr#) =
241245 let pinnedInt = I# (isMutableByteArrayPinned# arr#)
242246 in pinnedInt /= 0
243247
@@ -258,8 +262,8 @@ cloneMutableArrayWith# alloc# arr# s# =
258262 s3# -> (# s3#, arr1# #)
259263
260264{-# INLINE pin #-}
261−pin :: MutableByteArray -> IO MutableByteArray
262−pin arr@(MutableByteArray marr#) =
265+pin :: MutByteArray -> IO MutByteArray
266+pin arr@(MutByteArray marr#) =
263267 if isPinned arr
264268 then return arr
265269 else
@@ -271,11 +275,11 @@ pin arr@(MutableByteArray marr#) =
271275 IO
272276 $ \s# ->
273277 case cloneMutableArrayWith# newPinnedByteArray# marr# s# of
274− (# s1#, marr1# #) -> (# s1#, MutableByteArray marr1# #)
278+ (# s1#, marr1# #) -> (# s1#, MutByteArray marr1# #)
275279
276280{-# INLINE unpin #-}
277−unpin :: MutableByteArray -> IO MutableByteArray
278−unpin arr@(MutableByteArray marr#) =
281+unpin :: MutByteArray -> IO MutByteArray
282+unpin arr@(MutByteArray marr#) =
279283 if not (isPinned arr)
280284 then return arr
281285 else
@@ -287,7 +291,7 @@ unpin arr@(MutableByteArray marr#) =
287291 IO
288292 $ \s# ->
289293 case cloneMutableArrayWith# newByteArray# marr# s# of
290− (# s1#, marr1# #) -> (# s1#, MutableByteArray marr1# #)
294+ (# s1#, marr1# #) -> (# s1#, MutByteArray marr1# #)
291295
292296--------------------------------------------------------------------------------
293297-- The Unbox type class
@@ -458,11 +462,11 @@ class Unbox a where
458462 --
459463 -- IMPORTANT: The implementation of this interface may not check the bounds
460464 -- of the array, the caller must not assume that.
461− peekByteIndex :: Int -> MutableByteArray -> IO a
465+ peekByteIndex :: Int -> MutByteArray -> IO a
462466
463467 {-# INLINE peekByteIndex #-}
464468 default peekByteIndex :: (Generic a, PeekRep (Rep a)) =>
465− Int -> MutableByteArray -> IO a
469+ Int -> MutByteArray -> IO a
466470 peekByteIndex i arr = genericPeekByteIndex arr i
467471
468472 -- | @pokeByteIndex byte-index array@ writes an element of type @a@ to the
@@ -470,11 +474,11 @@ class Unbox a where
470474 --
471475 -- IMPORTANT: The implementation of this interface may not check the bounds
472476 -- of the array, the caller must not assume that.
473− pokeByteIndex :: Int -> MutableByteArray -> a -> IO ()
477+ pokeByteIndex :: Int -> MutByteArray -> a -> IO ()
474478
475479 {-# INLINE pokeByteIndex #-}
476480 default pokeByteIndex :: (Generic a, PokeRep (Rep a)) =>
477− Int -> MutableByteArray -> a -> IO ()
481+ Int -> MutByteArray -> a -> IO ()
478482 pokeByteIndex i arr = genericPokeByteIndex arr i
479483
480484-- XXX Add asserts to check bounds
@@ -482,11 +486,11 @@ class Unbox a where
482486#define DERIVE_UNBOXED(_type, _constructor, _readArray, _writeArray, _sizeOf) \
483487instance Unbox _type where { \
484488; {-# INLINE peekByteIndex #-} \
485−; peekByteIndex (I# n) (MutableByteArray mbarr) = IO $ \s -> \
489+; peekByteIndex (I# n) (MutByteArray mbarr) = IO $ \s -> \
486490 case _readArray mbarr n s of \
487491 { (# s1, i #) -> (# s1, _constructor i #) } \
488492; {-# INLINE pokeByteIndex #-} \
489−; pokeByteIndex (I# n) (MutableByteArray mbarr) (_constructor val) = \
493+; pokeByteIndex (I# n) (MutByteArray mbarr) (_constructor val) = \
490494 IO $ \s -> (# _writeArray mbarr n val s, () #) \
491495; {-# INLINE sizeOf #-} \
492496; sizeOf _ = _sizeOf \
@@ -681,7 +685,7 @@ instance Unbox Bool where
681685-- cheaper to just get the bound using the size of the array whenever needed?
682686data BoundedPtr =
683687 BoundedPtr
684− MutableByteArray -- byte array
688+ MutByteArray -- byte array
685689 Int -- current pos
686690 Int -- position after end
687691
@@ -966,7 +970,7 @@ genericPokeObj a ptr = void $ genericPokeObject a ptr
966970
967971{-# INLINE genericPokeByteIndex #-}
968972genericPokeByteIndex :: (Generic a, PokeRep (Rep a)) =>
969− MutableByteArray -> Int -> a -> IO ()
973+ MutByteArray -> Int -> a -> IO ()
970974genericPokeByteIndex arr index x = do
971975 -- XXX Should we use unsafe poke?
972976#ifdef DEBUG
@@ -1072,7 +1076,7 @@ genericPeekBoundedPtr = runPeeker genericPeeker
10721076
10731077{-# INLINE genericPeekByteIndex #-}
10741078genericPeekByteIndex :: (Generic a, PeekRep (Rep a)) =>
1075− MutableByteArray -> Int -> IO a
1079+ MutByteArray -> Int -> IO a
10761080genericPeekByteIndex arr index = do
10771081 -- XXX Should we use unsafe peek?
10781082#ifdef DEBUG
core/src/Streamly/Internal/Unicode/Stream.hs+4−4
@@ -109,7 +109,7 @@ import GHC.IO.Encoding.Failure (isSurrogate)
109109import GHC.Ptr (Ptr (..), plusPtr)
110110import System.IO.Unsafe (unsafePerformIO)
111111import Streamly.Internal.Data.Array.Type (Array(..))
112−import Streamly.Internal.Data.MutArray.Type (MutableByteArray)
112+import Streamly.Internal.Data.MutArray.Type (MutByteArray)
113113import Streamly.Internal.Data.Fold (Fold)
114114import Streamly.Internal.Data.Parser (Parser)
115115import Streamly.Internal.Data.Stream (Stream)
@@ -685,9 +685,9 @@ decodeUtf8Lax = decodeUtf8
685685#endif
686686data FlattenState s
687687 = OuterLoop s !(Maybe (DecodeState, CodePoint))
688− | InnerLoopDecodeInit s MutableByteArray !Int !Int
689− | InnerLoopDecodeFirst s MutableByteArray !Int !Int Word8
690− | InnerLoopDecoding s MutableByteArray !Int !Int
688+ | InnerLoopDecodeInit s MutByteArray !Int !Int
689+ | InnerLoopDecodeFirst s MutByteArray !Int !Int Word8
690+ | InnerLoopDecoding s MutByteArray !Int !Int
691691 !DecodeState !CodePoint
692692 | YAndC !Char (FlattenState s) -- These constructors can be
693693 -- encoded in the UTF8DecodeState
test/Streamly/Test/Data/Serialize.hs+3−3
@@ -22,7 +22,7 @@ module Streamly.Test.Data.Serialize (main) where
2222--------------------------------------------------------------------------------
2323
2424import System.Random (randomRIO)
25−import Streamly.Internal.Data.Serialize (MutableByteArray, newBytes)
25+import Streamly.Internal.Data.Serialize (MutByteArray, newBytes)
2626import GHC.Generics (Generic)
2727import Streamly.Data.Serialize (Serialize)
2828import Streamly.Test.Data.Serialize.TH (genDatatype)
@@ -158,7 +158,7 @@ testCompatibility v0 v1 = do
158158poke ::
159159 forall a. Serialize.Serialize a
160160 => a
161− -> IO (MutableByteArray, Int, Int)
161+ -> IO (MutByteArray, Int, Int)
162162poke val = do
163163 let sz = Serialize.size 0 val
164164
@@ -177,7 +177,7 @@ poke val = do
177177
178178peekAndVerify ::
179179 forall a. (Eq a, Show a, Serialize.Serialize a)
180− => (MutableByteArray, Int, Int)
180+ => (MutByteArray, Int, Int)
181181 -> a
182182 -> IO ()
183183peekAndVerify (arr, serStartOff, serEndOff) val = do
test/Streamly/Test/Data/Unbox.hs+2−2
@@ -72,7 +72,7 @@ import Test.Hspec as H
7272peekByteIndexWithNextOff ::
7373 forall a. Unbox a
7474 => Int
75− -> MutableByteArray
75+ -> MutByteArray
7676 -> IO (Int, a)
7777peekByteIndexWithNextOff i arr = do
7878 val <- peekByteIndex i arr
@@ -81,7 +81,7 @@ peekByteIndexWithNextOff i arr = do
8181pokeByteIndexWithNextOff ::
8282 forall a. Unbox a
8383 => Int
84− -> MutableByteArray
84+ -> MutByteArray
8585 -> a
8686 -> IO Int
8787pokeByteIndexWithNextOff i arr val = do