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.Mutable.Sized

This module re-exports the functionality in Data.Vector.Generic.Mutable.Sized specialized to Data.Vector.Mutable.

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 resulting vector size is not known until runtime are not exported.

  • 1 type
  • 46 values
typetype MVector = MVector MVector
#

Data.Vector.Generic.Mutable.Sized.Vector specialized to use Data.Vector.Storable.Mutable.

Accessors

0 declarations

Length information

Extracting subvectors

valueslice
  1. :: (KnownNat i, KnownNat n)
  2. => p i

    starting index

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

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

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

    starting index

  3. -> p n

    length

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

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

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

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

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

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

valuetake :: KnownNat n => MVector (n + k) s a -> MVector 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' :: KnownNat n => p n -> MVector (n + k) s a -> MVector 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 :: KnownNat n => MVector (n + k) s a -> MVector 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' :: KnownNat n => p n -> MVector (n + k) s a -> MVector 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
  2. => MVector (n + m) s a
  3. -> (MVector n s a, MVector 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
  2. => p n
  3. -> MVector (n + m) s a
  4. -> (MVector n s a, MVector 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

valuereplicateM
  1. :: (KnownNat n, PrimMonad m)
  2. => m a
  3. -> m (MVector n (PrimState m) a)
#

Create a mutable vector where the length is inferred from the type and fill it with values produced by repeatedly executing the monadic action.

valuereplicateM'
  1. :: (KnownNat n, PrimMonad m)
  2. => p n
  3. -> m a
  4. -> m (MVector n (PrimState m) a)
#

Create a mutable vector where the length is given explicitly as a Proxy argument and fill it with values produced by repeatedly executing the monadic action.

Growing

Restricting memory usage

valueclear :: PrimMonad m => MVector n (PrimState m) a -> m ()
#

Reset all elements of the vector to some undefined value, clearing all references to external objects.

Accessing individual elements

14 declarations

Modifying vectors

1 declaration

Filling and copying

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

    target

  3. -> MVector 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

valuewithSized
  1. :: MVector s a
  2. -> forall (n :: Nat). KnownNat n => MVector n s a -> r
  3. -> 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 n s a -> MVector 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.