-- Monadic indexing
-- ----------------

-- | /O(1)/ Indexing in a monad.
--
-- The monad allows operations to be strict in the vector when necessary.
-- Suppose vector copying is implemented like this:
--
-- > copy mv v = ... write mv i (v ! i) ...
--
-- For lazy vectors, @v ! i@ would not be evaluated which means that @mv@
-- would unnecessarily retain a reference to @v@ in each element written.
--
-- With 'indexM', copying can be implemented like this instead:
--
-- > copy mv v = ... do
-- >                   x <- indexM v i
-- >                   write mv i x
--
-- Here, no references to @v@ are retained because indexing (but /not/ the
-- elements) is evaluated eagerly.
--
indexM :: (Monad m, G.Vector (Vector k) (Rec (TaggedFunctor Identity) rs))
  => (Vector k) (Rec (TaggedFunctor Identity) rs) -> Int -> m (Rec (TaggedFunctor Identity) rs)
indexM = G.indexM
indexM :: (Monad m, G.Vector (Vector k) (Rec (TaggedFunctor Identity) rs))
  => (Vector k) (Rec (TaggedFunctor Identity) rs) -> Int -> m (Rec (TaggedFunctor Identity) rs)
indexM = G.indexM
indexM = G.indexM