HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

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.

  • 1 type
  • 46 values
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

0 declarations

Length information

Extracting subvectors

valueslice'
  1. :: (KnownNat i, KnownNat n, MVector v a)
  2. => p i

    starting index

  3. -> p n

    length

  4. -> MVector v ((i + n) + k) s a
  5. -> MVector v n s a
#

O(1) Yield a slice of the mutable vector without copying it with an explicit length argument.

valueinit :: MVector v a => MVector v (n + 1) s a -> MVector v n s a
#

O(1) Yield all but the last element of a non-empty mutable vector without copying.

valuetail :: MVector v a => MVector v (1 + n) s a -> MVector v n s a
#

O(1) Yield all but the first element of a non-empty mutable vector without copying.

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.

valuesplitAt
  1. :: (KnownNat n, MVector v a)
  2. => MVector v (n + m) s a
  3. -> (MVector v n s a, MVector v m s a)
#

O(1) Yield the first n elements, paired with the rest, without copying. The lengths of the resulting vectors are inferred from the type.

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

O(1) Yield the first n elements, paired with the rest, without copying. The length of the first resulting vector is passed explicitly as a Proxy argument.

Overlaps

Construction

0 declarations

Initialisation

Growing

Restricting memory usage

Accessing individual elements

14 declarations

Modifying vectors

1 declaration

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

0 declarations

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.