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

Modulebasement-0.0.16Haskell2010

Basement.BoxedArray

Simple boxed array abstraction

  • 2 types
  • 55 values
  • Packagebasement-0.0.16
  • Exports57
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceBoxedArray.hs
datadata Array a
#

Array of a

Instances15Functor, IsList, Eq, Data, Ord, Show, …
datadata MArray a st
#

Mutable Array of a

Instances1RandomAccess
  • (PrimMonad prim, st ~ PrimState prim) => RandomAccess (MArray ty st) prim tyDefined in basement-0.0.16 · Basement.BoxedArray
valuecopy :: Array ty -> Array ty
#

Copy the element to a new element array

valueunsafeCopyAtRO
  1. :: PrimMonad prim
  2. => MArray ty (PrimState prim)

    destination array

  3. -> Offset ty

    offset at destination

  4. -> Array ty

    source array

  5. -> Offset ty

    offset at source

  6. -> CountOf ty

    number of elements to copy

  7. -> prim ()
#

Copy n sequential elements from the specified offset in a source array to the specified position in a destination array.

This function does not check bounds. Accessing invalid memory can return unpredictable and invalid values.

valuethaw :: PrimMonad prim => Array ty -> prim (MArray ty (PrimState prim))
#

Thaw an array to a mutable array.

the array is not modified, instead a new mutable array is created and every values is copied, before returning the mutable array.

valuenew :: PrimMonad prim => CountOf ty -> prim (MArray ty (PrimState prim))
#

Create a new mutable array of size @n.

all the cells are uninitialized and could contains invalid values.

All mutable arrays are allocated on a 64 bits aligned addresses and always contains a number of bytes multiples of 64 bits.

valuecreate
  1. :: CountOf ty

    the size of the array

  2. -> (Offset ty -> ty)

    the function that set the value at the index

  3. -> Array ty

    the array created

#

Create a new array of size n by settings each cells through the function f.

valueunsafeWrite
  1. :: PrimMonad prim
  2. => MArray ty (PrimState prim)
  3. -> Offset ty
  4. -> ty
  5. -> prim ()
#

write to a cell in a mutable array without bounds checking.

Writing with invalid bounds will corrupt memory and your program will become unreliable. use write if unsure.

valueunsafeRead
  1. :: PrimMonad prim
  2. => MArray ty (PrimState prim)
  3. -> Offset ty
  4. -> prim ty
#

read from a cell in a mutable array without bounds checking.

Reading from invalid memory can return unpredictable and invalid values. use read if unsure.

valueunsafeIndex :: Array ty -> Offset ty -> ty
#

Return the element at a specific index from an array without bounds checking.

Reading from invalid memory can return unpredictable and invalid values. use index if unsure.

valueindex :: Array ty -> Offset ty -> ty
#

Return the element at a specific index from an array.

If the index @n is out of bounds, an error is raised.

valuefoldr :: (ty -> a -> a) -> a -> Array ty -> a
#