HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulevector-sized-1.6.1Haskell2010

Data.Vector.Generic.Mutable.Sized

This module reexports the functionality in Data.Vector.Generic.Mutable which maps well to explicitly sized vectors.

Functions returning a vector determine the size from the type context unless they have a ' suffix in which case they take an explicit Proxy argument.

Functions where the resultant vector size is not known until runtime are not exported.

Contents
  1. Accessors
  2. Length information
  3. Extracting subvectors
  4. Overlaps
  5. Construction
  6. Initialisation
  7. Growing
  8. Restricting memory usage
  9. Accessing individual elements
  10. Modifying vectors
  11. Filling and copying
  12. Conversions
  13. Unsized Mutable Vectors
Synopsis
newtypenewtype MVector (v :: Type -> Type -> Type) (n :: Nat) s a

A wrapper to tag mutable vectors with a type level length.

Be careful when using the constructor here to not construct sized vectors which have a different length than that specified in the type parameter!

Instances3Data, Storable, NFData

Accessors

Length information

Extracting subvectors

valuetake
  1. :: (KnownNat n, MVector v a)
  2. => MVector v (n + k) s a
  3. -> MVector v n s a

O(1) Yield the first n elements. The resulting vector always contains this many elements. The length of the resulting vector is inferred from the type.

valuetake'
  1. :: (KnownNat n, MVector v a)
  2. => p n
  3. -> MVector v (n + k) s a
  4. -> MVector v n s a

O(1) Yield the first n elements. The resulting vector always contains this many elements. The length of the resulting vector is given explicitly as a Proxy argument.

valuedrop
  1. :: (KnownNat n, MVector v a)
  2. => MVector v (n + k) s a
  3. -> MVector v k s a

O(1) Yield all but the the first n elements. The given vector must contain at least this many elements. The length of the resulting vector is inferred from the type.

valuedrop'
  1. :: (KnownNat n, MVector v a)
  2. => p n
  3. -> MVector v (n + k) s a
  4. -> MVector v k s a

O(1) Yield all but the the first n elements. The given vector must contain at least this many elements. The length of the resulting vector is given explicitly as a Proxy argument.

Overlaps

Construction

Initialisation

Growing

Restricting memory usage

Accessing individual elements

Modifying vectors

Filling and copying

valuemove
  1. :: (PrimMonad m, MVector v a)
  2. => MVector v n (PrimState m) a

    target

  3. -> MVector v n (PrimState m) a

    source

  4. -> m ()

Move the contents of a vector. If the two vectors do not overlap, this is equivalent to copy. Otherwise, the copying is performed as if the source vector were copied to a temporary vector and then the temporary vector was copied to the target vector.

Conversions

Unsized Mutable Vectors

valuetoSized :: (MVector v a, KnownNat n) => v s a -> Maybe (MVector v n s a)

Convert a MVector into a MVector if it has the correct size, otherwise return Nothing.

Note that this does no copying; the returned MVector is a reference to the exact same vector in memory as the given one, and any modifications to it are also reflected in the given MVector.

valuewithSized
  1. :: MVector v a
  2. => v s a
  3. -> forall (n :: Nat). KnownNat n => MVector v n s a -> r
  4. -> r

Takes a MVector and returns a continuation providing a MVector with a size parameter n that is determined at runtime based on the length of the input vector.

Essentially converts a MVector into a MVector with the correct size parameter n.

Note that this does no copying; the returned MVector is a reference to the exact same vector in memory as the given one, and any modifications to it are also reflected in the given MVector.

valuefromSized :: MVector v n s a -> v s a

Convert a MVector into a MVector.

Note that this does no copying; the returned MVector is a reference to the exact same vector in memory as the given one, and any modifications to it are also reflected in the given MVector.