snoyberg / mono-traversable

Type classes for mapping, folding, and traversing monomorphic containers
155 stars 67 forks source link

Mutable Indexing #221

Open BebeSparkelSparkel opened 4 months ago

BebeSparkelSparkel commented 4 months 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.