@@ -43,7 +43,7 @@ import Unsafe.Coerce
4343type role MVector nominal nominal
4444
4545-- | Mutable vectors of primitive types.
46- data MVector s a = MVector
46+ data MVector s a = UnsafeMVector
4747 { unsafeOffset :: ! Int
4848 -- ^ Offset into the `unsafeMutableByteArray` in number of elements, not bytes
4949 , unsafeSize :: ! Int
@@ -71,25 +71,25 @@ unsafeCoerceMVector = unsafeCoerce
7171-- | @since 0.13.0.0
7272unsafeCast :: forall a b s . (HasCallStack , Prim a , Prim b ) => MVector s a -> MVector s b
7373{-# INLINE unsafeCast #-}
74- unsafeCast (MVector o n ba)
75- | sizeOf (undefined :: a ) == sizeOf (undefined :: b ) = MVector o n ba
74+ unsafeCast (UnsafeMVector o n ba)
75+ | sizeOf (undefined :: a ) == sizeOf (undefined :: b ) = UnsafeMVector o n ba
7676 | otherwise = error " Element size mismatch"
7777
7878
7979
8080instance NFData (MVector s a ) where
81- rnf (MVector _ _ _) = ()
81+ rnf (UnsafeMVector _ _ _) = ()
8282
8383instance NFData1 (MVector s ) where
84- liftRnf _ (MVector _ _ _) = ()
84+ liftRnf _ (UnsafeMVector _ _ _) = ()
8585
8686instance Prim a => MG. MVector MVector a where
87- basicLength (MVector _ n _) = n
88- basicUnsafeSlice j m (MVector i _ arr)
89- = MVector (i+ j) m arr
87+ basicLength (UnsafeMVector _ n _) = n
88+ basicUnsafeSlice j m (UnsafeMVector i _ arr)
89+ = UnsafeMVector (i+ j) m arr
9090
9191 {-# INLINE basicOverlaps #-}
92- basicOverlaps (MVector i m arr1) (MVector j n arr2)
92+ basicOverlaps (UnsafeMVector i m arr1) (UnsafeMVector j n arr2)
9393 = sameMutableByteArray arr1 arr2
9494 && (between i j (j+ n) || between j i (i+ m))
9595 where
@@ -99,36 +99,36 @@ instance Prim a => MG.MVector MVector a where
9999 basicUnsafeNew n
100100 | n < 0 = error $ " Primitive.basicUnsafeNew: negative length: " ++ show n
101101 | n > mx = error $ " Primitive.basicUnsafeNew: length too large: " ++ show n
102- | otherwise = MVector 0 n `liftM` newByteArray (n * size)
102+ | otherwise = UnsafeMVector 0 n `liftM` newByteArray (n * size)
103103 where
104104 size = sizeOf (undefined :: a )
105105 mx = maxBound `div` size :: Int
106106
107107 {-# INLINE basicInitialize #-}
108- basicInitialize (MVector off n v) =
108+ basicInitialize (UnsafeMVector off n v) =
109109 setByteArray v (off * size) (n * size) (0 :: Word8 )
110110 where
111111 size = sizeOf (undefined :: a )
112112
113113
114114 {-# INLINE basicUnsafeRead #-}
115- basicUnsafeRead (MVector i _ arr) j = readByteArray arr (i+ j)
115+ basicUnsafeRead (UnsafeMVector i _ arr) j = readByteArray arr (i+ j)
116116
117117 {-# INLINE basicUnsafeWrite #-}
118- basicUnsafeWrite (MVector i _ arr) j x = writeByteArray arr (i+ j) x
118+ basicUnsafeWrite (UnsafeMVector i _ arr) j x = writeByteArray arr (i+ j) x
119119
120120 {-# INLINE basicUnsafeCopy #-}
121- basicUnsafeCopy (MVector i n dst) (MVector j _ src)
121+ basicUnsafeCopy (UnsafeMVector i n dst) (UnsafeMVector j _ src)
122122 = copyMutableByteArray dst (i* sz) src (j* sz) (n* sz)
123123 where
124124 sz = sizeOf (undefined :: a )
125125
126126 {-# INLINE basicUnsafeMove #-}
127- basicUnsafeMove (MVector i n dst) (MVector j _ src)
127+ basicUnsafeMove (UnsafeMVector i n dst) (UnsafeMVector j _ src)
128128 = moveByteArray dst (i* sz) src (j* sz) (n * sz)
129129 where
130130 sz = sizeOf (undefined :: a )
131131
132132 {-# INLINE basicSet #-}
133- basicSet (MVector i n arr) x = setByteArray arr i n x
133+ basicSet (UnsafeMVector i n arr) x = setByteArray arr i n x
134134
0 commit comments