@@ -21,8 +21,9 @@ module Data.Mutable.Class
2121 , MutableRef (.. )
2222 , MutableAtomicRef (.. )
2323 , MutableCollection (.. )
24- , MutableInitialSizedCollection (.. )
25- , MutableIndexing (.. )
24+ , MutableAllocatedCollection (.. )
25+ , CollIndex
26+ , MutableIndexingWrite (.. )
2627 , MutablePushFront (.. )
2728 , MutablePushBack (.. )
2829 , MutablePopFront (.. )
@@ -229,90 +230,85 @@ instance Monoid w => MutableCollection (MutVar s w) where
229230instance MutableCollection (MV. MVector s a ) where
230231 type CollElement (MV. MVector s a ) = a
231232 newColl = MV. new 0
232- {-# INLINE newColl #-}
233233instance MPV. Prim a => MutableCollection (MPV. MVector s a ) where
234234 type CollElement (MPV. MVector s a ) = a
235235 newColl = MPV. new 0
236- {-# INLINE newColl #-}
237236instance Storable a => MutableCollection (MSV. MVector s a ) where
238237 type CollElement (MSV. MVector s a ) = a
239238 newColl = MSV. new 0
240- {-# INLINE newColl #-}
241239instance MUV. Unbox a => MutableCollection (MUV. MVector s a ) where
242240 type CollElement (MUV. MVector s a ) = a
243241 newColl = MUV. new 0
244- {-# INLINE newColl #-}
245242instance (GHC.Arr. Ix i , Num i ) => MutableCollection (GHC.Arr. STArray s i e ) where
246243 type CollElement (GHC.Arr. STArray s i e ) = e
247244 newColl = primToPrim $ GHC.Arr. newSTArray (0 ,0 ) undefined
248- {-# INLINE newColl #-}
249245instance Storable a => MutableCollection (Ptr a ) where
250246 type CollElement (Ptr a ) = a
251247 newColl = primToPrim $ Foreign. mallocArray 0
252- {-# INLINE newColl #-}
253248
254249-- | Containers that can be initialized with n elements.
255- class MutableCollection c => MutableInitialSizedCollection c where
256- type CollIndex c
250+ type family CollIndex c
251+
252+ class MutableCollection c => MutableAllocatedCollection c where
257253 newCollOfSize :: (PrimMonad m , PrimState m ~ MCState c )
258254 => CollIndex c
259255 -> m c
260- instance MutableInitialSizedCollection (MV. MVector s a ) where
261- type CollIndex (MV. MVector s a ) = Int
256+ type instance CollIndex (MV. MVector s a ) = Int
257+ instance MutableAllocatedCollection (MV. MVector s a ) where
262258 newCollOfSize = MV. new
263259 {-# INLINE newCollOfSize #-}
264- instance MPV. Prim a => MutableInitialSizedCollection (MPV. MVector s a ) where
265- type CollIndex (MPV. MVector s a ) = Int
260+ type instance CollIndex (MPV. MVector s a ) = Int
261+ instance MPV. Prim a => MutableAllocatedCollection (MPV. MVector s a ) where
266262 newCollOfSize = MPV. new
267263 {-# INLINE newCollOfSize #-}
268- instance Storable a => MutableInitialSizedCollection (MSV. MVector s a ) where
269- type CollIndex (MSV. MVector s a ) = Int
264+ type instance CollIndex (MSV. MVector s a ) = Int
265+ instance Storable a => MutableAllocatedCollection (MSV. MVector s a ) where
270266 newCollOfSize = MSV. new
271267 {-# INLINE newCollOfSize #-}
272- instance MUV. Unbox a => MutableInitialSizedCollection (MUV. MVector s a ) where
273- type CollIndex (MUV. MVector s a ) = Int
268+ type instance CollIndex (MUV. MVector s a ) = Int
269+ instance MUV. Unbox a => MutableAllocatedCollection (MUV. MVector s a ) where
274270 newCollOfSize = MUV. new
275271 {-# INLINE newCollOfSize #-}
276- instance ( GHC.Arr. Ix i , Num i ) => MutableInitialSizedCollection (GHC.Arr. STArray s i e ) where
277- type CollIndex (GHC.Arr. STArray s i e ) = i
272+ type instance CollIndex (GHC.Arr. STArray s i e ) = i
273+ instance ( GHC.Arr. Ix i , Num i ) => MutableAllocatedCollection (GHC.Arr. STArray s i e ) where
278274 newCollOfSize x = primToPrim $ GHC.Arr. newSTArray (0 ,x) undefined
279275 {-# INLINE newCollOfSize #-}
280- instance Storable a => MutableInitialSizedCollection (Ptr a ) where
281- type CollIndex (Ptr a ) = Int
276+ type instance CollIndex (Ptr a ) = Int
277+ instance Storable a => MutableAllocatedCollection (Ptr a ) where
282278 newCollOfSize = primToPrim . Foreign. mallocArray
283279 {-# INLINE newCollOfSize #-}
284280
285- class MutableInitialSizedCollection c => MutableIndexing c where
286- readIndex :: (PrimMonad m , PrimState m ~ MCState c ) => c -> CollIndex c -> m (CollElement c )
281+ class MutableAllocatedCollection c => MutableIndexingWrite c where
282+ -- readIndex :: (PrimMonad m, PrimState m ~ MCState c) => c -> CollIndex c -> m (CollElement c)
287283 writeIndex :: (PrimMonad m , PrimState m ~ MCState c ) => c -> CollIndex c -> CollElement c -> m ()
288- instance MutableIndexing (MV. MVector s a ) where
289- readIndex = MV. read
290- {-# INLINE readIndex #-}
284+ instance MutableIndexingWrite (MV. MVector s a ) where
285+ -- readIndex = MV.read
286+ -- {-# INLINE readIndex #-}
291287 writeIndex = MV. write
292288 {-# INLINE writeIndex #-}
293- instance MPV. Prim a => MutableIndexing (MPV. MVector s a ) where
294- readIndex = MPV. read
295- {-# INLINE readIndex #-}
289+ instance MPV. Prim a => MutableIndexingWrite (MPV. MVector s a ) where
290+ -- readIndex = MPV.read
291+ -- {-# INLINE readIndex #-}
296292 writeIndex = MPV. write
297293 {-# INLINE writeIndex #-}
298- instance Storable a => MutableIndexing (MSV. MVector s a ) where
299- readIndex = MSV. read
300- {-# INLINE readIndex #-}
294+ instance Storable a => MutableIndexingWrite (MSV. MVector s a ) where
295+ -- readIndex = MSV.read
296+ -- {-# INLINE readIndex #-}
301297 writeIndex = MSV. write
302298 {-# INLINE writeIndex #-}
303- instance MUV. Unbox a => MutableIndexing (MUV. MVector s a ) where
304- readIndex = MUV. read
305- {-# INLINE readIndex #-}
299+ instance MUV. Unbox a => MutableIndexingWrite (MUV. MVector s a ) where
300+ -- readIndex = MUV.read
301+ -- {-# INLINE readIndex #-}
306302 writeIndex = MUV. write
307303 {-# INLINE writeIndex #-}
308- instance (GHC.Arr. Ix i , Num i ) => MutableIndexing (GHC.Arr. STArray s i e ) where
309- readIndex c i = primToPrim $ GHC.Arr. readSTArray c i
310- {-# INLINE readIndex #-}
304+ instance (GHC.Arr. Ix i , Num i ) => MutableIndexingWrite (GHC.Arr. STArray s i e ) where
305+ -- readIndex c i = primToPrim $ GHC.Arr.readSTArray c i
306+ -- {-# INLINE readIndex #-}
311307 writeIndex c i e = primToPrim $ GHC.Arr. writeSTArray c i e
312308 {-# INLINE writeIndex #-}
313- instance Storable a => MutableIndexing (Ptr a ) where
314- readIndex p i = primToPrim $ Foreign. peekElemOff p i
315- {-# INLINE readIndex #-}
309+ instance Storable a => MutableIndexingWrite (Ptr a ) where
310+ -- readIndex p i = primToPrim $ Foreign.peekElemOff p i
311+ -- {-# INLINE readIndex #-}
316312 writeIndex p i e = primToPrim $ Foreign. pokeElemOff p i e
317313 {-# INLINE writeIndex #-}
318314
0 commit comments