HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Modulecontiguous-0.6.5.0Haskell2010

Data.Primitive.Contiguous.Class

The Contiguous typeclass parameterises over a contiguous array type. It provides the core primitives necessary to implement the common API in Data.Primitive.Contiguous. This allows us to have a common API to a number of contiguous array types and their mutable counterparts.

  • 2 types
  • 3 classes
classclass Contiguous (arr :: Type -> Type) where
#

The Contiguous typeclass as an interface to a multitude of contiguous structures.

Some functions do not make sense on slices; for those, see ContiguousU.

Associated types

  • type family Mutable (arr :: Type -> Type) :: Type -> Type -> Type

    The Mutable counterpart to the array.

  • type family Element (arr :: Type -> Type) :: Type -> Constraint

    The constraint needed to store elements in the array.

  • type family Sliced (arr :: Type -> Type) :: Type -> Type

    The slice type of this array. The slice of a raw array type t should be 'Slice t', whereas the slice of a slice should be the same slice type.

  • type family MutableSliced (arr :: Type -> Type) :: Type -> Type -> Type

    The mutable slice type of this array. The mutable slice of a raw array type t should be 'MutableSlice t', whereas the mutable slice of a mutable slice should be the same slice type.

Methods

Instances6Contiguous
datadata Slice (arr :: Type -> Type) a
#

Slices of immutable arrays: packages an offset and length with a backing array.

Constructors

Instances5Contiguous, Element, Mutable, MutableSliced, Sliced
classclass Contiguous arr => ContiguousU (arr :: Type -> Type) where
#

The ContiguousU typeclass is an extension of the Contiguous typeclass, but includes operations that make sense only on unsliced contiguous structures.

Associated types

Methods

  • resize :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> m (Mutable arr (PrimState m) b)

    Resize an array into one with the given size. If the array is grown, then reading from any newly introduced element before writing to it is undefined behavior. The current behavior is that anything backed by MutableByteArray# ends with uninitialized memory at these indices. But for SmallMutableArray or Array, these are set to an error thunk, so reading from them and forcing the result causes the program to crash. For UnliftedArray, the new elements have undefined values of an unknown type. If the array is not grown, it may (or may not) be modified in place.

  • unlift :: arr b -> Unlifted arr b

    Unlift an array (i.e. point to the data without an intervening thunk).

  • unliftMut :: Mutable arr s b -> UnliftedMut arr s b

    Unlift a mutable array (i.e. point to the data without an intervening thunk).

  • lift :: Unlifted arr b -> arr b

    Lift an array (i.e. point to the data through an intervening thunk).

  • liftMut :: UnliftedMut arr s b -> Mutable arr s b

    Lift a mutable array (i.e. point to the data through an intervening thunk).

Instances5ContiguousU
classclass Always a
#

A typeclass that is satisfied by all types. This is used used to provide a fake constraint for Array and SmallArray.

Instances1Always
  • Always aDefined in contiguous-0.6.5.0 · Data.Primitive.Contiguous.Class