Data.Primitive.Contiguous.Class

contiguous-0.6.4.2: Unified interface for primitive arrays

Safe Haskell | None
Language | Haskell2010

Data.Primitive.Contiguous.Class

Description

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.

Synopsis

- class Contiguous (arr :: Type -> Type) where
  - type Mutable (arr :: Type -> Type) = (r :: Type -> Type -> Type) | r -> arr
  - type Element (arr :: Type -> Type) :: Type -> Constraint
  - type Sliced (arr :: Type -> Type) :: Type -> Type
  - type MutableSliced (arr :: Type -> Type) :: Type -> Type -> Type
  - new :: (PrimMonad m, Element arr b) => Int -> m (Mutable arr (PrimState m) b)
  - replicateMut :: (PrimMonad m, Element arr b) => Int -> b -> m (Mutable arr (PrimState m) b)
  - shrink :: (PrimMonad m, Element arr a) => Mutable arr (PrimState m) a -> Int -> m (Mutable arr (PrimState m) a)
  - empty :: arr a
  - singleton :: Element arr a => a -> arr a
  - doubleton :: Element arr a => a -> a -> arr a
  - tripleton :: Element arr a => a -> a -> a -> arr a
  - quadrupleton :: Element arr a => a -> a -> a -> a -> arr a
  - quintupleton :: Element arr a => a -> a -> a -> a -> a -> arr a
  - sextupleton :: Element arr a => a -> a -> a -> a -> a -> a -> arr a
  - index :: Element arr b => arr b -> Int -> b
  - index# :: Element arr b => arr b -> Int -> (# b #)
  - indexM :: (Element arr b, Monad m) => arr b -> Int -> m b
  - read :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> m b
  - write :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> b -> m ()
  - null :: arr b -> Bool
  - size :: Element arr b => arr b -> Int
  - sizeMut :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> m Int
  - equals :: (Element arr b, Eq b) => arr b -> arr b -> Bool
  - equalsMut :: Mutable arr s a -> Mutable arr s a -> Bool
  - slice :: Element arr a => arr a -> Int -> Int -> Sliced arr a
  - sliceMut :: Element arr a => Mutable arr s a -> Int -> Int -> MutableSliced arr s a
  - toSlice :: Element arr a => arr a -> Sliced arr a
  - toSliceMut :: (PrimMonad m, Element arr a) => Mutable arr (PrimState m) a -> m (MutableSliced arr (PrimState m) a)
  - clone :: Element arr b => Sliced arr b -> arr b
  - clone_ :: Element arr a => arr a -> Int -> Int -> arr a
  - cloneMut :: (PrimMonad m, Element arr b) => MutableSliced arr (PrimState m) b -> m (Mutable arr (PrimState m) b)
  - cloneMut_ :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> Int -> m (Mutable arr (PrimState m) b)
  - freeze :: (PrimMonad m, Element arr a) => MutableSliced arr (PrimState m) a -> m (arr a)
  - freeze_ :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> Int -> m (arr b)
  - unsafeFreeze :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> m (arr b)
  - unsafeShrinkAndFreeze :: (PrimMonad m, Element arr a) => Mutable arr (PrimState m) a -> Int -> m (arr a)
  - thaw :: (PrimMonad m, Element arr b) => Sliced arr b -> m (Mutable arr (PrimState m) b)
  - thaw_ :: (PrimMonad m, Element arr b) => arr b -> Int -> Int -> m (Mutable arr (PrimState m) b)
  - copy :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> Sliced arr b -> m ()
  - copy_ :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> arr b -> Int -> Int -> m ()
  - copyMut :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> MutableSliced arr (PrimState m) b -> m ()
  - copyMut_ :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> Mutable arr (PrimState m) b -> Int -> Int -> m ()
  - insertAt :: Element arr b => arr b -> Int -> b -> arr b
  - rnf :: (NFData a, Element arr a) => arr a -> ()
  - run :: (forall s. ST s (arr a)) -> arr a
- data Slice (arr :: Type -> Type) a = Slice {
  - offset :: !Int
  - length :: !Int
  - base :: !(Unlifted arr a)
  }
- data MutableSlice (arr :: Type -> Type) s a = MutableSlice {
  - offsetMut :: !Int
  - lengthMut :: !Int
  - baseMut :: !(UnliftedMut arr s a)
  }
- class Contiguous arr => ContiguousU (arr :: Type -> Type) where
  - type Unlifted (arr :: Type -> Type) = (r :: Type -> UnliftedType) | r -> arr
  - type UnliftedMut (arr :: Type -> Type) = (r :: Type -> Type -> UnliftedType) | r -> arr
  - resize :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> m (Mutable arr (PrimState m) b)
  - unlift :: arr b -> Unlifted arr b
  - unliftMut :: Mutable arr s b -> UnliftedMut arr s b
  - lift :: Unlifted arr b -> arr b
  - liftMut :: UnliftedMut arr s b -> Mutable arr s b
- class Always a

# Documentation

class 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`.

Minimal complete definition

new, replicateMut, empty, singleton, doubleton, tripleton, quadrupleton, quintupleton, sextupleton, index, index#, indexM, read, write, null, size, sizeMut, equals, equalsMut, slice, sliceMut, toSlice, toSliceMut, clone_, cloneMut_, freeze_, thaw_, copy_, copyMut_, rnf, run

Associated Types

type Mutable (arr :: Type -> Type) = (r :: Type -> Type -> Type) | r -> arr #

The Mutable counterpart to the array.

type Element (arr :: Type -> Type) :: Type -> Constraint #

The constraint needed to store elements in the array.

type 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.

Since: 0.6.0

type 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.

Since: 0.6.0

Methods

new :: (PrimMonad m, Element arr b) => Int -> m (Mutable arr (PrimState m) b) #

Allocate a new mutable array of the given size.

replicateMut :: (PrimMonad m, Element arr b) => Int -> b -> m (Mutable arr (PrimState m) b) #

``replicateMut` n x` is a mutable array of length `n` with `x` the value of every element.

shrink #

Arguments

:: (PrimMonad m, Element arr a) |
=> Mutable arr (PrimState m) a |
-> Int | new length
-> m (Mutable arr (PrimState m) a) |

Resize an array without growing it.

Since: 0.6.0

default shrink :: (ContiguousU arr, PrimMonad m, Element arr a) => Mutable arr (PrimState m) a -> Int -> m (Mutable arr (PrimState m) a) #

empty :: arr a #

The empty array.

singleton :: Element arr a => a -> arr a #

Create a singleton array.

doubleton :: Element arr a => a -> a -> arr a #

Create a doubleton array.

tripleton :: Element arr a => a -> a -> a -> arr a #

Create a tripleton array.

quadrupleton :: Element arr a => a -> a -> a -> a -> arr a #

Create a quadrupleton array.

quintupleton :: Element arr a => a -> a -> a -> a -> a -> arr a #

Create a quintupleton array.

sextupleton :: Element arr a => a -> a -> a -> a -> a -> a -> arr a #

Create a sextupleton array.

index :: Element arr b => arr b -> Int -> b #

Index into an array at the given index.

index# :: Element arr b => arr b -> Int -> (# b #) #

Index into an array at the given index, yielding an unboxed one-tuple of the element.

indexM :: (Element arr b, Monad m) => arr b -> Int -> m b #

Indexing in a monad.

The monad allows operations to be strict in the array when necessary. Suppose array copying is implemented like this:

    copy mv v = ... write mv i (v ! i) ...

For lazy arrays, `v ! i` would not be not be evaluated, which means that `mv` would unnecessarily retain a reference to `v` in each element written.

With `indexM`, copying can be implemented like this instead:

    copy mv v = ... do
      x <- indexM v i
      write mv i x

Here, no references to `v` are retained because indexing (but not the elements) is evaluated eagerly.

read :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> m b #

Read a mutable array at the given index.

write :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> b -> m () #

Write to a mutable array at the given index.

null :: arr b -> Bool #

Test whether the array is empty.

size :: Element arr b => arr b -> Int #

The size of the array

sizeMut :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> m Int #

The size of the mutable array

equals :: (Element arr b, Eq b) => arr b -> arr b -> Bool #

Test the two arrays for equality.

equalsMut :: Mutable arr s a -> Mutable arr s a -> Bool #

Test the two mutable arrays for pointer equality. Does not check equality of elements.

slice :: Element arr a => arr a -> Int -> Int -> Sliced arr a #

Create a `Slice` of an array.

`O(1)`.

Since: 0.6.0

sliceMut :: Element arr a => Mutable arr s a -> Int -> Int -> MutableSliced arr s a #

Create a `MutableSlice` of a mutable array.

`O(1)`.

Since: 0.6.0

toSlice :: Element arr a => arr a -> Sliced arr a #

Create a `Slice` that covers the entire array.

Since: 0.6.0

toSliceMut :: (PrimMonad m, Element arr a) => Mutable arr (PrimState m) a -> m (MutableSliced arr (PrimState m) a) #

Create a `MutableSlice` that covers the entire array.

Since: 0.6.0

clone #

Arguments

:: Element arr b |
=> Sliced arr b | slice to copy
-> arr b |

Clone a slice of an array.

default clone :: (Sliced arr ~ Slice arr, ContiguousU arr, Element arr b) => Sliced arr b -> arr b #

clone_ :: Element arr a => arr a -> Int -> Int -> arr a #

Clone a slice of an array without using the `Slice` type. These methods are required to implement 'Contiguous (Slice arr)' for any `Contiguous arr`; they are not really meant for direct use.

Since: 0.6.0

cloneMut #

Arguments

:: (PrimMonad m, Element arr b) |
=> MutableSliced arr (PrimState m) b | Array to copy a slice of
-> m (Mutable arr (PrimState m) b) |

Clone a slice of a mutable array.

default cloneMut :: (MutableSliced arr ~ MutableSlice arr, ContiguousU arr, PrimMonad m, Element arr b) => MutableSliced arr (PrimState m) b -> m (Mutable arr (PrimState m) b) #

cloneMut_ #

Arguments

:: (PrimMonad m, Element arr b) |
=> Mutable arr (PrimState m) b | Array to copy a slice of
-> Int | offset
-> Int | length
-> m (Mutable arr (PrimState m) b) |

Clone a slice of a mutable array without using the `MutableSlice` type. These methods are required to implement 'Contiguous (Slice arr)' for any `Contiguous arr`; they are not really meant for direct use.

Since: 0.6.0

freeze :: (PrimMonad m, Element arr a) => MutableSliced arr (PrimState m) a -> m (arr a) #

Turn a mutable array slice an immutable array by copying.

Since: 0.6.0

default freeze :: (MutableSliced arr ~ MutableSlice arr, ContiguousU arr, PrimMonad m, Element arr a) => MutableSliced arr (PrimState m) a -> m (arr a) #

freeze_ #

Arguments

:: (PrimMonad m, Element arr b) |
=> Mutable arr (PrimState m) b |
-> Int | offset
-> Int | length
-> m (arr b) |

Turn a slice of a mutable array into an immutable one with copying, without using the `MutableSlice` type. These methods are required to implement 'Contiguous (Slice arr)' for any `Contiguous arr`; they are not really meant for direct use.

Since: 0.6.0

unsafeFreeze :: (PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> m (arr b) #

Turn a mutable array into an immutable one without copying. The mutable array should not be used after this conversion.

unsafeShrinkAndFreeze #

Arguments

:: (PrimMonad m, Element arr a) |
=> Mutable arr (PrimState m) a |
-> Int | final size
-> m (arr a) |

default unsafeShrinkAndFreeze :: (ContiguousU arr, PrimMonad m, Element arr a) => Mutable arr (PrimState m) a -> Int -> m (arr a) #

thaw :: (PrimMonad m, Element arr b) => Sliced arr b -> m (Mutable arr (PrimState m) b) #

Copy a slice of an immutable array into a new mutable array.

default thaw :: (Sliced arr ~ Slice arr, ContiguousU arr, PrimMonad m, Element arr b) => Sliced arr b -> m (Mutable arr (PrimState m) b) #

thaw_ #

Arguments

:: (PrimMonad m, Element arr b) |
=> arr b |
-> Int | offset into the array
-> Int | length of the slice
-> m (Mutable arr (PrimState m) b) |

Copy a slice of an immutable array into a new mutable array without using the `Slice` type. These methods are required to implement 'Contiguous (Slice arr)' for any `Contiguous arr`; they are not really meant for direct use.

Since: 0.6.0

copy #

Arguments

:: (PrimMonad m, Element arr b) |
=> Mutable arr (PrimState m) b | destination array
-> Int | offset into destination array
-> Sliced arr b | source slice
-> m () |

Copy a slice of an array into a mutable array.

default copy :: (Sliced arr ~ Slice arr, ContiguousU arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> Sliced arr b -> m () #

copy_ #

Arguments

:: (PrimMonad m, Element arr b) |
=> Mutable arr (PrimState m) b | destination array
-> Int | offset into destination array
-> arr b | source array
-> Int | offset into source array
-> Int | number of elements to copy
-> m () |

Copy a slice of an array into a mutable array without using the `Slice` type. These methods are required to implement 'Contiguous (Slice arr)' for any `Contiguous arr`; they are not really meant for direct use.

Since: 0.6.0

copyMut #

Arguments

:: (PrimMonad m, Element arr b) |
=> Mutable arr (PrimState m) b | destination array
-> Int | offset into destination array
-> MutableSliced arr (PrimState m) b | source slice
-> m () |

Copy a slice of a mutable array into another mutable array. In the case that the destination and source arrays are the same, the regions may overlap.

default copyMut :: (MutableSliced arr ~ MutableSlice arr, ContiguousU arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> MutableSliced arr (PrimState m) b -> m () #

copyMut_ #

Arguments

:: (PrimMonad m, Element arr b) |
=> Mutable arr (PrimState m) b | destination array
-> Int | offset into destination array
-> Mutable arr (PrimState m) b | source array
-> Int | offset into source array
-> Int | number of elements to copy
-> m () |

Copy a slice of a mutable array into another mutable array without using the `Slice` type. These methods are required to implement 'Contiguous (Slice arr)' for any `Contiguous arr`; they are not really meant for direct use.

Since: 0.6.0

insertAt #

Arguments

:: Element arr b |
=> arr b | slice to copy from
-> Int | index in the output array to insert at
-> b | element to insert
-> arr b |

Copy a slice of an array and then insert an element into that array.

The default implementation performs a memset which would be unnecessary except that the garbage collector might trace the uninitialized array.

Was previously `insertSlicing` @since 0.6.0

default insertAt :: (Element arr b, ContiguousU arr) => arr b -> Int -> b -> arr b #

rnf :: (NFData a, Element arr a) => arr a -> () #

Reduce the array and all of its elements to WHNF.

run :: (forall s. ST s (arr a)) -> arr a #

Run an effectful computation that produces an array.

#### Instances

Instances details

Contiguous Array # |
Instance details Defined in Data.Primitive.Contiguous.Class Associated Types
type Mutable Array |
Instance details Defined in Data.Primitive.Contiguous.Class type Mutable Array = MutableArray
type Element Array |
Instance details Defined in Data.Primitive.Contiguous.Class type Element Array = Always
type Sliced Array |
Instance details Defined in Data.Primitive.Contiguous.Class type Sliced Array = Slice Array
type MutableSliced Array |
Instance details Defined in Data.Primitive.Contiguous.Class type MutableSliced Array = MutableSlice Array
Methods new :: (PrimMonad m, Element Array b) => Int -> m (Mutable Array (PrimState m) b) # replicateMut :: (PrimMonad m, Element Array b) => Int -> b -> m (Mutable Array (PrimState m) b) # shrink :: (PrimMonad m, Element Array a) => Mutable Array (PrimState m) a -> Int -> m (Mutable Array (PrimState m) a) # empty :: Array a # singleton :: Element Array a => a -> Array a # doubleton :: Element Array a => a -> a -> Array a # tripleton :: Element Array a => a -> a -> a -> Array a # quadrupleton :: Element Array a => a -> a -> a -> a -> Array a # quintupleton :: Element Array a => a -> a -> a -> a -> a -> Array a # sextupleton :: Element Array a => a -> a -> a -> a -> a -> a -> Array a # index :: Element Array b => Array b -> Int -> b # index# :: Element Array b => Array b -> Int -> (# b #) # indexM :: (Element Array b, Monad m) => Array b -> Int -> m b # read :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> Int -> m b # write :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> Int -> b -> m () # null :: Array b -> Bool # size :: Element Array b => Array b -> Int # sizeMut :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> m Int # equals :: (Element Array b, Eq b) => Array b -> Array b -> Bool # equalsMut :: Mutable Array s a -> Mutable Array s a -> Bool # slice :: Element Array a => Array a -> Int -> Int -> Sliced Array a # sliceMut :: Element Array a => Mutable Array s a -> Int -> Int -> MutableSliced Array s a # toSlice :: Element Array a => Array a -> Sliced Array a # toSliceMut :: (PrimMonad m, Element Array a) => Mutable Array (PrimState m) a -> m (MutableSliced Array (PrimState m) a) # clone :: Element Array b => Sliced Array b -> Array b # clone_ :: Element Array a => Array a -> Int -> Int -> Array a # cloneMut :: (PrimMonad m, Element Array b) => MutableSliced Array (PrimState m) b -> m (Mutable Array (PrimState m) b) # cloneMut_ :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> Int -> Int -> m (Mutable Array (PrimState m) b) # freeze :: (PrimMonad m, Element Array a) => MutableSliced Array (PrimState m) a -> m (Array a) # freeze_ :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> Int -> Int -> m (Array b) # unsafeFreeze :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> m (Array b) # unsafeShrinkAndFreeze :: (PrimMonad m, Element Array a) => Mutable Array (PrimState m) a -> Int -> m (Array a) # thaw :: (PrimMonad m, Element Array b) => Sliced Array b -> m (Mutable Array (PrimState m) b) # thaw_ :: (PrimMonad m, Element Array b) => Array b -> Int -> Int -> m (Mutable Array (PrimState m) b) # copy :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> Int -> Sliced Array b -> m () # copy_ :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> Int -> Array b -> Int -> Int -> m () # copyMut :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> Int -> MutableSliced Array (PrimState m) b -> m () # copyMut_ :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> Int -> Mutable Array (PrimState m) b -> Int -> Int -> m () # insertAt :: Element Array b => Array b -> Int -> b -> Array b # rnf :: (NFData a, Element Array a) => Array a -> () # run :: (forall s. ST s (Array a)) -> Array a #
Contiguous PrimArray # |
Instance details Defined in Data.Primitive.Contiguous.Class Associated Types
type Mutable PrimArray |
Instance details Defined in Data.Primitive.Contiguous.Class type Mutable PrimArray = MutablePrimArray
type Element PrimArray |
Instance details Defined in Data.Primitive.Contiguous.Class type Element PrimArray = Prim
type Sliced PrimArray |
Instance details Defined in Data.Primitive.Contiguous.Class type Sliced PrimArray = Slice PrimArray
type MutableSliced PrimArray |
Instance details Defined in Data.Primitive.Contiguous.Class type MutableSliced PrimArray = MutableSlice PrimArray
Methods new :: (PrimMonad m, Element PrimArray b) => Int -> m (Mutable PrimArray (PrimState m) b) # replicateMut :: (PrimMonad m, Element PrimArray b) => Int -> b -> m (Mutable PrimArray (PrimState m) b) # shrink :: (PrimMonad m, Element PrimArray a) => Mutable PrimArray (PrimState m) a -> Int -> m (Mutable PrimArray (PrimState m) a) # empty :: PrimArray a # singleton :: Element PrimArray a => a -> PrimArray a # doubleton :: Element PrimArray a => a -> a -> PrimArray a # tripleton :: Element PrimArray a => a -> a -> a -> PrimArray a # quadrupleton :: Element PrimArray a => a -> a -> a -> a -> PrimArray a # quintupleton :: Element PrimArray a => a -> a -> a -> a -> a -> PrimArray a # sextupleton :: Element PrimArray a => a -> a -> a -> a -> a -> a -> PrimArray a # index :: Element PrimArray b => PrimArray b -> Int -> b # index# :: Element PrimArray b => PrimArray b -> Int -> (# b #) # indexM :: (Element PrimArray b, Monad m) => PrimArray b -> Int -> m b # read :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> Int -> m b # write :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> Int -> b -> m () # null :: PrimArray b -> Bool # size :: Element PrimArray b => PrimArray b -> Int # sizeMut :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> m Int # equals :: (Element PrimArray b, Eq b) => PrimArray b -> PrimArray b -> Bool # equalsMut :: Mutable PrimArray s a -> Mutable PrimArray s a -> Bool # slice :: Element PrimArray a => PrimArray a -> Int -> Int -> Sliced PrimArray a # sliceMut :: Element PrimArray a => Mutable PrimArray s a -> Int -> Int -> MutableSliced PrimArray s a # toSlice :: Element PrimArray a => PrimArray a -> Sliced PrimArray a # toSliceMut :: (PrimMonad m, Element PrimArray a) => Mutable PrimArray (PrimState m) a -> m (MutableSliced PrimArray (PrimState m) a) # clone :: Element PrimArray b => Sliced PrimArray b -> PrimArray b # clone_ :: Element PrimArray a => PrimArray a -> Int -> Int -> PrimArray a # cloneMut :: (PrimMonad m, Element PrimArray b) => MutableSliced PrimArray (PrimState m) b -> m (Mutable PrimArray (PrimState m) b) # cloneMut_ :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> Int -> Int -> m (Mutable PrimArray (PrimState m) b) # freeze :: (PrimMonad m, Element PrimArray a) => MutableSliced PrimArray (PrimState m) a -> m (PrimArray a) # freeze_ :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> Int -> Int -> m (PrimArray b) # unsafeFreeze :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> m (PrimArray b) # unsafeShrinkAndFreeze :: (PrimMonad m, Element PrimArray a) => Mutable PrimArray (PrimState m) a -> Int -> m (PrimArray a) # thaw :: (PrimMonad m, Element PrimArray b) => Sliced PrimArray b -> m (Mutable PrimArray (PrimState m) b) # thaw_ :: (PrimMonad m, Element PrimArray b) => PrimArray b -> Int -> Int -> m (Mutable PrimArray (PrimState m) b) # copy :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> Int -> Sliced PrimArray b -> m () # copy_ :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> Int -> PrimArray b -> Int -> Int -> m () # copyMut :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> Int -> MutableSliced PrimArray (PrimState m) b -> m () # copyMut_ :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> Int -> Mutable PrimArray (PrimState m) b -> Int -> Int -> m () # insertAt :: Element PrimArray b => PrimArray b -> Int -> b -> PrimArray b # rnf :: (NFData a, Element PrimArray a) => PrimArray a -> () # run :: (forall s. ST s (PrimArray a)) -> PrimArray a #
Contiguous SmallArray # |
Instance details Defined in Data.Primitive.Contiguous.Class Associated Types
type Mutable SmallArray |
Instance details Defined in Data.Primitive.Contiguous.Class type Mutable SmallArray = SmallMutableArray
type Element SmallArray |
Instance details Defined in Data.Primitive.Contiguous.Class type Element SmallArray = Always
type Sliced SmallArray |
Instance details Defined in Data.Primitive.Contiguous.Class type Sliced SmallArray = Slice SmallArray
type MutableSliced SmallArray |
Instance details Defined in Data.Primitive.Contiguous.Class type MutableSliced SmallArray = MutableSlice SmallArray
Methods new :: (PrimMonad m, Element SmallArray b) => Int -> m (Mutable SmallArray (PrimState m) b) # replicateMut :: (PrimMonad m, Element SmallArray b) => Int -> b -> m (Mutable SmallArray (PrimState m) b) # shrink :: (PrimMonad m, Element SmallArray a) => Mutable SmallArray (PrimState m) a -> Int -> m (Mutable SmallArray (PrimState m) a) # empty :: SmallArray a # singleton :: Element SmallArray a => a -> SmallArray a # doubleton :: Element SmallArray a => a -> a -> SmallArray a # tripleton :: Element SmallArray a => a -> a -> a -> SmallArray a # quadrupleton :: Element SmallArray a => a -> a -> a -> a -> SmallArray a # quintupleton :: Element SmallArray a => a -> a -> a -> a -> a -> SmallArray a # sextupleton :: Element SmallArray a => a -> a -> a -> a -> a -> a -> SmallArray a # index :: Element SmallArray b => SmallArray b -> Int -> b # index# :: Element SmallArray b => SmallArray b -> Int -> (# b #) # indexM :: (Element SmallArray b, Monad m) => SmallArray b -> Int -> m b # read :: (PrimMonad m, Element SmallArray b) => Mutable SmallArray (PrimState m) b -> Int -> m b # write :: (PrimMonad m, Element SmallArray b) => Mutable SmallArray (PrimState m) b -> Int -> b -> m () # null :: SmallArray b -> Bool # size :: Element SmallArray b => SmallArray b -> Int # sizeMut :: (PrimMonad m, Element SmallArray b) => Mutable SmallArray (PrimState m) b -> m Int # equals :: (Element SmallArray b, Eq b) => SmallArray b -> SmallArray b -> Bool # equalsMut :: Mutable SmallArray s a -> Mutable SmallArray s a -> Bool # slice :: Element SmallArray a => SmallArray a -> Int -> Int -> Sliced SmallArray a # sliceMut :: Element SmallArray a => Mutable SmallArray s a -> Int -> Int -> MutableSliced SmallArray s a # toSlice :: Element SmallArray a => SmallArray a -> Sliced SmallArray a # toSliceMut :: (PrimMonad m, Element SmallArray a) => Mutable SmallArray (PrimState m) a -> m (MutableSliced SmallArray (PrimState m) a) # clone :: Element SmallArray b => Sliced SmallArray b -> SmallArray b # clone_ :: Element SmallArray a => SmallArray a -> Int -> Int -> SmallArray a # cloneMut :: (PrimMonad m, Element SmallArray b) => MutableSliced SmallArray (PrimState m) b -> m (Mutable SmallArray (PrimState m) b) # cloneMut_ :: (PrimMonad m, Element SmallArray b) => Mutable SmallArray (PrimState m) b -> Int -> Int -> m (Mutable SmallArray (PrimState m) b) # freeze :: (PrimMonad m, Element SmallArray a) => MutableSliced SmallArray (PrimState m) a -> m (SmallArray a) # freeze_ :: (PrimMonad m, Element SmallArray b) => Mutable SmallArray (PrimState m) b -> Int -> Int -> m (SmallArray b) # unsafeFreeze :: (PrimMonad m, Element SmallArray b) => Mutable SmallArray (PrimState m) b -> m (SmallArray b) # unsafeShrinkAndFreeze :: (PrimMonad m, Element SmallArray a) => Mutable SmallArray (PrimState m) a -> Int -> m (SmallArray a) # thaw :: (PrimMonad m, Element SmallArray b) => Sliced SmallArray b -> m (Mutable SmallArray (PrimState m) b) # thaw_ :: (PrimMonad m, Element SmallArray b) => SmallArray b -> Int -> Int -> m (Mutable SmallArray (PrimState m) b) # copy :: (PrimMonad m, Element SmallArray b) => Mutable SmallArray (PrimState m) b -> Int -> Sliced SmallArray b -> m () # copy_ :: (PrimMonad m, Element SmallArray b) => Mutable SmallArray (PrimState m) b -> Int -> SmallArray b -> Int -> Int -> m () # copyMut :: (PrimMonad m, Element SmallArray b) => Mutable SmallArray (PrimState m) b -> Int -> MutableSliced SmallArray (PrimState m) b -> m () # copyMut_ :: (PrimMonad m, Element SmallArray b) => Mutable SmallArray (PrimState m) b -> Int -> Mutable SmallArray (PrimState m) b -> Int -> Int -> m () # insertAt :: Element SmallArray b => SmallArray b -> Int -> b -> SmallArray b # rnf :: (NFData a, Element SmallArray a) => SmallArray a -> () # run :: (forall s. ST s (SmallArray a)) -> SmallArray a #
ContiguousU arr => Contiguous (Slice arr) # |
Instance details Defined in Data.Primitive.Contiguous.Class Associated Types
type Mutable (Slice arr) |
Instance details Defined in Data.Primitive.Contiguous.Class type Mutable (Slice arr) = MutableSlice arr
type Element (Slice arr) |
Instance details Defined in Data.Primitive.Contiguous.Class type Element (Slice arr) = Element arr
type Sliced (Slice arr) |
Instance details Defined in Data.Primitive.Contiguous.Class type Sliced (Slice arr) = Slice arr
type MutableSliced (Slice arr) |
Instance details Defined in Data.Primitive.Contiguous.Class type MutableSliced (Slice arr) = MutableSlice arr
Methods new :: (PrimMonad m, Element (Slice arr) b) => Int -> m (Mutable (Slice arr) (PrimState m) b) # replicateMut :: (PrimMonad m, Element (Slice arr) b) => Int -> b -> m (Mutable (Slice arr) (PrimState m) b) # shrink :: (PrimMonad m, Element (Slice arr) a) => Mutable (Slice arr) (PrimState m) a -> Int -> m (Mutable (Slice arr) (PrimState m) a) # empty :: Slice arr a # singleton :: Element (Slice arr) a => a -> Slice arr a # doubleton :: Element (Slice arr) a => a -> a -> Slice arr a # tripleton :: Element (Slice arr) a => a -> a -> a -> Slice arr a # quadrupleton :: Element (Slice arr) a => a -> a -> a -> a -> Slice arr a # quintupleton :: Element (Slice arr) a => a -> a -> a -> a -> a -> Slice arr a # sextupleton :: Element (Slice arr) a => a -> a -> a -> a -> a -> a -> Slice arr a # index :: Element (Slice arr) b => Slice arr b -> Int -> b # index# :: Element (Slice arr) b => Slice arr b -> Int -> (# b #) # indexM :: (Element (Slice arr) b, Monad m) => Slice arr b -> Int -> m b # read :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> m b # write :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> b -> m () # null :: Slice arr b -> Bool # size :: Element (Slice arr) b => Slice arr b -> Int # sizeMut :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> m Int # equals :: (Element (Slice arr) b, Eq b) => Slice arr b -> Slice arr b -> Bool # equalsMut :: Mutable (Slice arr) s a -> Mutable (Slice arr) s a -> Bool # slice :: Element (Slice arr) a => Slice arr a -> Int -> Int -> Sliced (Slice arr) a # sliceMut :: Element (Slice arr) a => Mutable (Slice arr) s a -> Int -> Int -> MutableSliced (Slice arr) s a # toSlice :: Element (Slice arr) a => Slice arr a -> Sliced (Slice arr) a # toSliceMut :: (PrimMonad m, Element (Slice arr) a) => Mutable (Slice arr) (PrimState m) a -> m (MutableSliced (Slice arr) (PrimState m) a) # clone :: Element (Slice arr) b => Sliced (Slice arr) b -> Slice arr b # clone_ :: Element (Slice arr) a => Slice arr a -> Int -> Int -> Slice arr a # cloneMut :: (PrimMonad m, Element (Slice arr) b) => MutableSliced (Slice arr) (PrimState m) b -> m (Mutable (Slice arr) (PrimState m) b) # cloneMut_ :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> Int -> m (Mutable (Slice arr) (PrimState m) b) # freeze :: (PrimMonad m, Element (Slice arr) a) => MutableSliced (Slice arr) (PrimState m) a -> m (Slice arr a) # freeze_ :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> Int -> m (Slice arr b) # unsafeFreeze :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> m (Slice arr b) # unsafeShrinkAndFreeze :: (PrimMonad m, Element (Slice arr) a) => Mutable (Slice arr) (PrimState m) a -> Int -> m (Slice arr a) # thaw :: (PrimMonad m, Element (Slice arr) b) => Sliced (Slice arr) b -> m (Mutable (Slice arr) (PrimState m) b) # thaw_ :: (PrimMonad m, Element (Slice arr) b) => Slice arr b -> Int -> Int -> m (Mutable (Slice arr) (PrimState m) b) # copy :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> Sliced (Slice arr) b -> m () # copy_ :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> Slice arr b -> Int -> Int -> m () # copyMut :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> MutableSliced (Slice arr) (PrimState m) b -> m () # copyMut_ :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> Mutable (Slice arr) (PrimState m) b -> Int -> Int -> m () # insertAt :: Element (Slice arr) b => Slice arr b -> Int -> b -> Slice arr b # rnf :: (NFData a, Element (Slice arr) a) => Slice arr a -> () # run :: (forall s. ST s (Slice arr a)) -> Slice arr a #
Contiguous (UnliftedArray_ unlifted_a) # |
Instance details Defined in Data.Primitive.Contiguous.Class Associated Types
type Mutable (UnliftedArray_ unlifted_a) |
Instance details Defined in Data.Primitive.Contiguous.Class type Mutable (UnliftedArray_ unlifted_a) = MutableUnliftedArray_ unlifted_a
type Element (UnliftedArray_ unlifted_a) |
Instance details Defined in Data.Primitive.Contiguous.Class type Element (UnliftedArray_ unlifted_a)
type Sliced (UnliftedArray_ unlifted_a) |
Instance details Defined in Data.Primitive.Contiguous.Class type Sliced (UnliftedArray_ unlifted_a) = Slice (UnliftedArray_ unlifted_a)
type MutableSliced (UnliftedArray_ unlifted_a) |
Instance details Defined in Data.Primitive.Contiguous.Class type MutableSliced (UnliftedArray_ unlifted_a) = MutableSlice (UnliftedArray_ unlifted_a)
Methods new :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => Int -> m (Mutable (UnliftedArray_ unlifted_a) (PrimState m) b) # replicateMut :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => Int -> b -> m (Mutable (UnliftedArray_ unlifted_a) (PrimState m) b) # shrink :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) a) => Mutable (UnliftedArray_ unlifted_a) (PrimState m) a -> Int -> m (Mutable (UnliftedArray_ unlifted_a) (PrimState m) a) # empty :: UnliftedArray_ unlifted_a a # singleton :: Element (UnliftedArray_ unlifted_a) a => a -> UnliftedArray_ unlifted_a a # doubleton :: Element (UnliftedArray_ unlifted_a) a => a -> a -> UnliftedArray_ unlifted_a a # tripleton :: Element (UnliftedArray_ unlifted_a) a => a -> a -> a -> UnliftedArray_ unlifted_a a # quadrupleton :: Element (UnliftedArray_ unlifted_a) a => a -> a -> a -> a -> UnliftedArray_ unlifted_a a # quintupleton :: Element (UnliftedArray_ unlifted_a) a => a -> a -> a -> a -> a -> UnliftedArray_ unlifted_a a # sextupleton :: Element (UnliftedArray_ unlifted_a) a => a -> a -> a -> a -> a -> a -> UnliftedArray_ unlifted_a a # index :: Element (UnliftedArray_ unlifted_a) b => UnliftedArray_ unlifted_a b -> Int -> b # index# :: Element (UnliftedArray_ unlifted_a) b => UnliftedArray_ unlifted_a b -> Int -> (# b #) # indexM :: (Element (UnliftedArray_ unlifted_a) b, Monad m) => UnliftedArray_ unlifted_a b -> Int -> m b # read :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => Mutable (UnliftedArray_ unlifted_a) (PrimState m) b -> Int -> m b # write :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => Mutable (UnliftedArray_ unlifted_a) (PrimState m) b -> Int -> b -> m () # null :: UnliftedArray_ unlifted_a b -> Bool # size :: Element (UnliftedArray_ unlifted_a) b => UnliftedArray_ unlifted_a b -> Int # sizeMut :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => Mutable (UnliftedArray_ unlifted_a) (PrimState m) b -> m Int # equals :: (Element (UnliftedArray_ unlifted_a) b, Eq b) => UnliftedArray_ unlifted_a b -> UnliftedArray_ unlifted_a b -> Bool # equalsMut :: Mutable (UnliftedArray_ unlifted_a) s a -> Mutable (UnliftedArray_ unlifted_a) s a -> Bool # slice :: Element (UnliftedArray_ unlifted_a) a => UnliftedArray_ unlifted_a a -> Int -> Int -> Sliced (UnliftedArray_ unlifted_a) a # sliceMut :: Element (UnliftedArray_ unlifted_a) a => Mutable (UnliftedArray_ unlifted_a) s a -> Int -> Int -> MutableSliced (UnliftedArray_ unlifted_a) s a # toSlice :: Element (UnliftedArray_ unlifted_a) a => UnliftedArray_ unlifted_a a -> Sliced (UnliftedArray_ unlifted_a) a # toSliceMut :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) a) => Mutable (UnliftedArray_ unlifted_a) (PrimState m) a -> m (MutableSliced (UnliftedArray_ unlifted_a) (PrimState m) a) # clone :: Element (UnliftedArray_ unlifted_a) b => Sliced (UnliftedArray_ unlifted_a) b -> UnliftedArray_ unlifted_a b # clone_ :: Element (UnliftedArray_ unlifted_a) a => UnliftedArray_ unlifted_a a -> Int -> Int -> UnliftedArray_ unlifted_a a # cloneMut :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => MutableSliced (UnliftedArray_ unlifted_a) (PrimState m) b -> m (Mutable (UnliftedArray_ unlifted_a) (PrimState m) b) # cloneMut_ :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => Mutable (UnliftedArray_ unlifted_a) (PrimState m) b -> Int -> Int -> m (Mutable (UnliftedArray_ unlifted_a) (PrimState m) b) # freeze :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) a) => MutableSliced (UnliftedArray_ unlifted_a) (PrimState m) a -> m (UnliftedArray_ unlifted_a a) # freeze_ :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => Mutable (UnliftedArray_ unlifted_a) (PrimState m) b -> Int -> Int -> m (UnliftedArray_ unlifted_a b) # unsafeFreeze :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => Mutable (UnliftedArray_ unlifted_a) (PrimState m) b -> m (UnliftedArray_ unlifted_a b) # unsafeShrinkAndFreeze :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) a) => Mutable (UnliftedArray_ unlifted_a) (PrimState m) a -> Int -> m (UnliftedArray_ unlifted_a a) # thaw :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => Sliced (UnliftedArray_ unlifted_a) b -> m (Mutable (UnliftedArray_ unlifted_a) (PrimState m) b) # thaw_ :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => UnliftedArray_ unlifted_a b -> Int -> Int -> m (Mutable (UnliftedArray_ unlifted_a) (PrimState m) b) # copy :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => Mutable (UnliftedArray_ unlifted_a) (PrimState m) b -> Int -> Sliced (UnliftedArray_ unlifted_a) b -> m () # copy_ :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => Mutable (UnliftedArray_ unlifted_a) (PrimState m) b -> Int -> UnliftedArray_ unlifted_a b -> Int -> Int -> m () # copyMut :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => Mutable (UnliftedArray_ unlifted_a) (PrimState m) b -> Int -> MutableSliced (UnliftedArray_ unlifted_a) (PrimState m) b -> m () # copyMut_ :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => Mutable (UnliftedArray_ unlifted_a) (PrimState m) b -> Int -> Mutable (UnliftedArray_ unlifted_a) (PrimState m) b -> Int -> Int -> m () # insertAt :: Element (UnliftedArray_ unlifted_a) b => UnliftedArray_ unlifted_a b -> Int -> b -> UnliftedArray_ unlifted_a b # rnf :: (NFData a, Element (UnliftedArray_ unlifted_a) a) => UnliftedArray_ unlifted_a a -> () # run :: (forall s. ST s (UnliftedArray_ unlifted_a a)) -> UnliftedArray_ unlifted_a a #

data Slice (arr :: Type -> Type) a #

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

Since: 0.6.0

Constructors

Slice |
Fields offset :: !Int length :: !Int base :: !(Unlifted arr a)

#### Instances

Instances details

ContiguousU arr => Contiguous (Slice arr) # |
Instance details Defined in Data.Primitive.Contiguous.Class Associated Types
type Mutable (Slice arr) |
Instance details Defined in Data.Primitive.Contiguous.Class type Mutable (Slice arr) = MutableSlice arr
type Element (Slice arr) |
Instance details Defined in Data.Primitive.Contiguous.Class type Element (Slice arr) = Element arr
type Sliced (Slice arr) |
Instance details Defined in Data.Primitive.Contiguous.Class type Sliced (Slice arr) = Slice arr
type MutableSliced (Slice arr) |
Instance details Defined in Data.Primitive.Contiguous.Class type MutableSliced (Slice arr) = MutableSlice arr
Methods new :: (PrimMonad m, Element (Slice arr) b) => Int -> m (Mutable (Slice arr) (PrimState m) b) # replicateMut :: (PrimMonad m, Element (Slice arr) b) => Int -> b -> m (Mutable (Slice arr) (PrimState m) b) # shrink :: (PrimMonad m, Element (Slice arr) a) => Mutable (Slice arr) (PrimState m) a -> Int -> m (Mutable (Slice arr) (PrimState m) a) # empty :: Slice arr a # singleton :: Element (Slice arr) a => a -> Slice arr a # doubleton :: Element (Slice arr) a => a -> a -> Slice arr a # tripleton :: Element (Slice arr) a => a -> a -> a -> Slice arr a # quadrupleton :: Element (Slice arr) a => a -> a -> a -> a -> Slice arr a # quintupleton :: Element (Slice arr) a => a -> a -> a -> a -> a -> Slice arr a # sextupleton :: Element (Slice arr) a => a -> a -> a -> a -> a -> a -> Slice arr a # index :: Element (Slice arr) b => Slice arr b -> Int -> b # index# :: Element (Slice arr) b => Slice arr b -> Int -> (# b #) # indexM :: (Element (Slice arr) b, Monad m) => Slice arr b -> Int -> m b # read :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> m b # write :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> b -> m () # null :: Slice arr b -> Bool # size :: Element (Slice arr) b => Slice arr b -> Int # sizeMut :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> m Int # equals :: (Element (Slice arr) b, Eq b) => Slice arr b -> Slice arr b -> Bool # equalsMut :: Mutable (Slice arr) s a -> Mutable (Slice arr) s a -> Bool # slice :: Element (Slice arr) a => Slice arr a -> Int -> Int -> Sliced (Slice arr) a # sliceMut :: Element (Slice arr) a => Mutable (Slice arr) s a -> Int -> Int -> MutableSliced (Slice arr) s a # toSlice :: Element (Slice arr) a => Slice arr a -> Sliced (Slice arr) a # toSliceMut :: (PrimMonad m, Element (Slice arr) a) => Mutable (Slice arr) (PrimState m) a -> m (MutableSliced (Slice arr) (PrimState m) a) # clone :: Element (Slice arr) b => Sliced (Slice arr) b -> Slice arr b # clone_ :: Element (Slice arr) a => Slice arr a -> Int -> Int -> Slice arr a # cloneMut :: (PrimMonad m, Element (Slice arr) b) => MutableSliced (Slice arr) (PrimState m) b -> m (Mutable (Slice arr) (PrimState m) b) # cloneMut_ :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> Int -> m (Mutable (Slice arr) (PrimState m) b) # freeze :: (PrimMonad m, Element (Slice arr) a) => MutableSliced (Slice arr) (PrimState m) a -> m (Slice arr a) # freeze_ :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> Int -> m (Slice arr b) # unsafeFreeze :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> m (Slice arr b) # unsafeShrinkAndFreeze :: (PrimMonad m, Element (Slice arr) a) => Mutable (Slice arr) (PrimState m) a -> Int -> m (Slice arr a) # thaw :: (PrimMonad m, Element (Slice arr) b) => Sliced (Slice arr) b -> m (Mutable (Slice arr) (PrimState m) b) # thaw_ :: (PrimMonad m, Element (Slice arr) b) => Slice arr b -> Int -> Int -> m (Mutable (Slice arr) (PrimState m) b) # copy :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> Sliced (Slice arr) b -> m () # copy_ :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> Slice arr b -> Int -> Int -> m () # copyMut :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> MutableSliced (Slice arr) (PrimState m) b -> m () # copyMut_ :: (PrimMonad m, Element (Slice arr) b) => Mutable (Slice arr) (PrimState m) b -> Int -> Mutable (Slice arr) (PrimState m) b -> Int -> Int -> m () # insertAt :: Element (Slice arr) b => Slice arr b -> Int -> b -> Slice arr b # rnf :: (NFData a, Element (Slice arr) a) => Slice arr a -> () # run :: (forall s. ST s (Slice arr a)) -> Slice arr a #
type Element (Slice arr) # |
Instance details Defined in Data.Primitive.Contiguous.Class type Element (Slice arr) = Element arr
type Mutable (Slice arr) # |
Instance details Defined in Data.Primitive.Contiguous.Class type Mutable (Slice arr) = MutableSlice arr
type MutableSliced (Slice arr) # |
Instance details Defined in Data.Primitive.Contiguous.Class type MutableSliced (Slice arr) = MutableSlice arr
type Sliced (Slice arr) # |
Instance details Defined in Data.Primitive.Contiguous.Class type Sliced (Slice arr) = Slice arr

data MutableSlice (arr :: Type -> Type) s a #

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

Since: 0.6.0

Constructors

MutableSlice |
Fields offsetMut :: !Int lengthMut :: !Int baseMut :: !(UnliftedMut arr s a)

class 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.

Since: 0.6.0

Associated Types

type Unlifted (arr :: Type -> Type) = (r :: Type -> UnliftedType) | r -> arr #

The unifted version of the immutable array type (i.e. eliminates an indirection through a thunk).

type UnliftedMut (arr :: Type -> Type) = (r :: Type -> Type -> UnliftedType) | r -> arr #

The unifted version of the mutable array type (i.e. eliminates an indirection through a thunk).

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.

unlift :: arr b -> Unlifted arr b #

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

Since: 0.6.0

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

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

Since: 0.6.0

lift :: Unlifted arr b -> arr b #

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

Since: 0.6.0

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

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

Since: 0.6.0

#### Instances

Instances details

ContiguousU Array # |
Instance details Defined in Data.Primitive.Contiguous.Class Associated Types
type Unlifted Array |
Instance details Defined in Data.Primitive.Contiguous.Class type Unlifted Array = Array# :: Type -> UnliftedType
type UnliftedMut Array |
Instance details Defined in Data.Primitive.Contiguous.Class type UnliftedMut Array = MutableArray# :: Type -> Type -> UnliftedType
Methods resize :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> Int -> m (Mutable Array (PrimState m) b) # unlift :: Array b -> Unlifted Array b # unliftMut :: Mutable Array s b -> UnliftedMut Array s b # lift :: Unlifted Array b -> Array b # liftMut :: UnliftedMut Array s b -> Mutable Array s b #
ContiguousU PrimArray # |
Instance details Defined in Data.Primitive.Contiguous.Class Associated Types
type Unlifted PrimArray |
Instance details Defined in Data.Primitive.Contiguous.Class type Unlifted PrimArray
type UnliftedMut PrimArray |
Instance details Defined in Data.Primitive.Contiguous.Class type UnliftedMut PrimArray
Methods resize :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> Int -> m (Mutable PrimArray (PrimState m) b) # unlift :: PrimArray b -> Unlifted PrimArray b # unliftMut :: Mutable PrimArray s b -> UnliftedMut PrimArray s b # lift :: Unlifted PrimArray b -> PrimArray b # liftMut :: UnliftedMut PrimArray s b -> Mutable PrimArray s b #
ContiguousU SmallArray # |
Instance details Defined in Data.Primitive.Contiguous.Class Associated Types
type Unlifted SmallArray |
Instance details Defined in Data.Primitive.Contiguous.Class type Unlifted SmallArray = SmallArray# :: Type -> UnliftedType
type UnliftedMut SmallArray |
Instance details Defined in Data.Primitive.Contiguous.Class type UnliftedMut SmallArray = SmallMutableArray# :: Type -> Type -> UnliftedType
Methods resize :: (PrimMonad m, Element SmallArray b) => Mutable SmallArray (PrimState m) b -> Int -> m (Mutable SmallArray (PrimState m) b) # unlift :: SmallArray b -> Unlifted SmallArray b # unliftMut :: Mutable SmallArray s b -> UnliftedMut SmallArray s b # lift :: Unlifted SmallArray b -> SmallArray b # liftMut :: UnliftedMut SmallArray s b -> Mutable SmallArray s b #
ContiguousU (UnliftedArray_ unlifted_a) # |
Instance details Defined in Data.Primitive.Contiguous.Class Associated Types
type Unlifted (UnliftedArray_ unlifted_a) |
Instance details Defined in Data.Primitive.Contiguous.Class type Unlifted (UnliftedArray_ unlifted_a)
type UnliftedMut (UnliftedArray_ unlifted_a) |
Instance details Defined in Data.Primitive.Contiguous.Class type UnliftedMut (UnliftedArray_ unlifted_a)
Methods resize :: (PrimMonad m, Element (UnliftedArray_ unlifted_a) b) => Mutable (UnliftedArray_ unlifted_a) (PrimState m) b -> Int -> m (Mutable (UnliftedArray_ unlifted_a) (PrimState m) b) # unlift :: UnliftedArray_ unlifted_a b -> Unlifted (UnliftedArray_ unlifted_a) b # unliftMut :: Mutable (UnliftedArray_ unlifted_a) s b -> UnliftedMut (UnliftedArray_ unlifted_a) s b # lift :: Unlifted (UnliftedArray_ unlifted_a) b -> UnliftedArray_ unlifted_a b # liftMut :: UnliftedMut (UnliftedArray_ unlifted_a) s b -> Mutable (UnliftedArray_ unlifted_a) s b #

class Always a #

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

#### Instances

Instances details

Always a # |
Instance details Defined in Data.Primitive.Contiguous.Class