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

Modulelinear-base-0.4.0Haskell2010

Data.Array.Mutable.Linear.Internal

  • 1 type
  • 17 values

Mutable Linear Arrays

1 declaration
datadata Array a
#

Constructors

Instances3Functor, Consumable, Dupable
  • Functor ArrayDefined in linear-base-0.4.0 · Data.Array.Mutable.Linear.Internal
  • Consumable (Array a)Defined in linear-base-0.4.0 · Data.Array.Mutable.Linear.Internal
  • Dupable (Array a)Defined in linear-base-0.4.0 · Data.Array.Mutable.Linear.Internal

Performing Computations with Arrays

3 declarations
valuealloc :: HasCallStack => Int -> a -> (Array a %1 -> Ur b) %1 -> Ur b
#

Allocate a constant array given a size and an initial value The size must be non-negative, otherwise this errors.

valueallocBeside :: Int -> a -> Array b %1 -> (Array a, Array b)
#

Allocate a constant array given a size and an initial value, using another array as a uniqueness proof.

Modifications

4 declarations
valueset :: HasCallStack => Int -> a -> Array a %1 -> Array a
#

Sets the value of an index. The index should be less than the arrays size, otherwise this errors.

valueunsafeSet :: Int -> a -> Array a %1 -> Array a
#

Same as set, but does not do bounds-checking. The behaviour is undefined if an out-of-bounds index is provided.

valueresize :: HasCallStack => Int -> a -> Array a %1 -> Array a
#

Resize an array. That is, given an array, a target size, and a seed value; resize the array to the given size using the seed value to fill in the new cells when necessary and copying over all the unchanged cells.

Target size should be non-negative.

let b = resize n x a,
  then size b = n,
  and b[i] = a[i] for i < size a,
  and b[i] = x for size a <= i < n.

Accessors

6 declarations
valueunsafeGet :: Int -> Array a %1 -> (Ur a, Array a)
#

Same as get, but does not do bounds-checking. The behaviour is undefined if an out-of-bounds index is provided.

valueslice
  1. :: HasCallStack
  2. => Int

    Start offset

  3. -> Int

    Target size

  4. -> Array a
  5. -> (Array a, Array a)
#

Copy a slice of the array, starting from given offset and copying given number of elements. Returns the pair (oldArray, slice).

Start offset + target size should be within the input array, and both should be non-negative.

let b = slice i n a,
  then size b = n,
  and b[j] = a[i+j] for 0 <= j < n
valuetoList :: Array a %1 -> Ur [a]
#

Return the array elements as a lazy list.

Mutable-style interface

4 declarations