snoyberg / mono-traversable

Type classes for mapping, folding, and traversing monomorphic containers
152 stars 61 forks source link

Mutable Indexing #221

Open BebeSparkelSparkel opened 1 week ago

BebeSparkelSparkel commented 1 week ago

mutable-containers currently seems to only support deques and queues. Adding

class MutableCollection c => MutableInitialSizedCollection c where
  type CollIndex c :: Type
  newCollOfSize :: (PrimMonad m, PrimState m ~ MCState c) => CollIndex c -> m c

class MutableInitialSizedCollection c => MutableIndexing c where
  readIndex :: (PrimMonad m, PrimState m ~ MCState c) => c -> CollIndex c -> m (CollElement c)
  writeIndex :: (PrimMonad m, PrimState m ~ MCState c) => c -> CollIndex c -> CollElement c -> m ()

would allow mutable indexing.