contiguous-checked-0.3.2.0: contiguous with bounds checks

Safe HaskellNone
LanguageHaskell2010

Data.Primitive.Contiguous

Contents

Synopsis

Documentation

class Contiguous (arr :: Type -> Type) #

A contiguous array of elements.

Instances
Contiguous Array 
Instance details

Defined in Data.Primitive.Contiguous

Associated Types

type Mutable Array = (r :: Type -> Type -> Type) #

type Element Array :: Type -> Constraint #

Methods

empty :: Array a #

null :: Array b -> Bool #

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

replicateM :: (PrimMonad m, Element Array b) => Int -> b -> m (Mutable Array (PrimState m) b) #

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 () #

resize :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> Int -> m (Mutable Array (PrimState m) b) #

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

sizeMutable :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> m Int #

unsafeFreeze :: PrimMonad m => Mutable Array (PrimState m) b -> m (Array 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 -> Array b -> Int -> Int -> m () #

copyMutable :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> Int -> Mutable Array (PrimState m) b -> Int -> Int -> m () #

clone :: Element Array b => Array b -> Int -> Int -> Array b #

cloneMutable :: (PrimMonad m, Element Array b) => Mutable Array (PrimState m) b -> Int -> Int -> m (Mutable Array (PrimState m) b) #

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

unlift :: Array b -> ArrayArray# #

lift :: ArrayArray# -> Array b #

sameMutable :: Mutable Array s a -> Mutable Array s a -> Bool #

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

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

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

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

Contiguous UnliftedArray 
Instance details

Defined in Data.Primitive.Contiguous

Associated Types

type Mutable UnliftedArray = (r :: Type -> Type -> Type) #

type Element UnliftedArray :: Type -> Constraint #

Methods

empty :: UnliftedArray a #

null :: UnliftedArray b -> Bool #

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

replicateM :: (PrimMonad m, Element UnliftedArray b) => Int -> b -> m (Mutable UnliftedArray (PrimState m) b) #

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

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

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

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

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

resize :: (PrimMonad m, Element UnliftedArray b) => Mutable UnliftedArray (PrimState m) b -> Int -> m (Mutable UnliftedArray (PrimState m) b) #

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

sizeMutable :: (PrimMonad m, Element UnliftedArray b) => Mutable UnliftedArray (PrimState m) b -> m Int #

unsafeFreeze :: PrimMonad m => Mutable UnliftedArray (PrimState m) b -> m (UnliftedArray b) #

thaw :: (PrimMonad m, Element UnliftedArray b) => UnliftedArray b -> Int -> Int -> m (Mutable UnliftedArray (PrimState m) b) #

copy :: (PrimMonad m, Element UnliftedArray b) => Mutable UnliftedArray (PrimState m) b -> Int -> UnliftedArray b -> Int -> Int -> m () #

copyMutable :: (PrimMonad m, Element UnliftedArray b) => Mutable UnliftedArray (PrimState m) b -> Int -> Mutable UnliftedArray (PrimState m) b -> Int -> Int -> m () #

clone :: Element UnliftedArray b => UnliftedArray b -> Int -> Int -> UnliftedArray b #

cloneMutable :: (PrimMonad m, Element UnliftedArray b) => Mutable UnliftedArray (PrimState m) b -> Int -> Int -> m (Mutable UnliftedArray (PrimState m) b) #

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

unlift :: UnliftedArray b -> ArrayArray# #

lift :: ArrayArray# -> UnliftedArray b #

sameMutable :: Mutable UnliftedArray s a -> Mutable UnliftedArray s a -> Bool #

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

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

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

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

Contiguous PrimArray 
Instance details

Defined in Data.Primitive.Contiguous

Associated Types

type Mutable PrimArray = (r :: Type -> Type -> Type) #

type Element PrimArray :: Type -> Constraint #

Methods

empty :: PrimArray a #

null :: PrimArray b -> Bool #

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

replicateM :: (PrimMonad m, Element PrimArray b) => Int -> b -> m (Mutable PrimArray (PrimState m) b) #

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 () #

resize :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> Int -> m (Mutable PrimArray (PrimState m) b) #

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

sizeMutable :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> m Int #

unsafeFreeze :: PrimMonad m => Mutable PrimArray (PrimState m) b -> m (PrimArray 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 -> PrimArray b -> Int -> Int -> m () #

copyMutable :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> Int -> Mutable PrimArray (PrimState m) b -> Int -> Int -> m () #

clone :: Element PrimArray b => PrimArray b -> Int -> Int -> PrimArray b #

cloneMutable :: (PrimMonad m, Element PrimArray b) => Mutable PrimArray (PrimState m) b -> Int -> Int -> m (Mutable PrimArray (PrimState m) b) #

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

unlift :: PrimArray b -> ArrayArray# #

lift :: ArrayArray# -> PrimArray b #

sameMutable :: Mutable PrimArray s a -> Mutable PrimArray s a -> Bool #

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

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

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

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

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

Instances
type Element Array 
Instance details

Defined in Data.Primitive.Contiguous

type Element UnliftedArray 
Instance details

Defined in Data.Primitive.Contiguous

type Element PrimArray 
Instance details

Defined in Data.Primitive.Contiguous

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

Instances
type Mutable Array 
Instance details

Defined in Data.Primitive.Contiguous

type Mutable UnliftedArray 
Instance details

Defined in Data.Primitive.Contiguous

type Mutable PrimArray 
Instance details

Defined in Data.Primitive.Contiguous

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
Always a 
Instance details

Defined in Data.Primitive.Contiguous

Primitives

empty :: Contiguous arr => arr a #

null :: Contiguous arr => arr b -> Bool #

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

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

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

index :: (HasCallStack, Contiguous arr, Element arr b) => arr b -> Int -> b Source #

index# :: (HasCallStack, Contiguous arr, Element arr b) => arr b -> Int -> (#b#) Source #

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

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

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

resize :: (HasCallStack, Contiguous arr, Element arr b, PrimMonad m) => Mutable arr (PrimState m) b -> Int -> m (Mutable arr (PrimState m) b) Source #

size :: (Contiguous arr, Element arr b) => arr b -> Int #

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

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

copy :: (HasCallStack, Contiguous arr, Element arr b, PrimMonad m) => Mutable arr (PrimState m) b -> Int -> arr b -> Int -> Int -> m () Source #

copyMutable :: (HasCallStack, Contiguous arr, Element arr b, PrimMonad m) => Mutable arr (PrimState m) b -> Int -> Mutable arr (PrimState m) b -> Int -> Int -> m () Source #

clone :: (HasCallStack, Contiguous arr, Element arr b) => arr b -> Int -> Int -> arr b Source #

cloneMutable :: (HasCallStack, Contiguous arr, Element arr b, PrimMonad m) => Mutable arr (PrimState m) b -> Int -> Int -> m (Mutable arr (PrimState m) b) Source #

thaw :: (HasCallStack, Contiguous arr, PrimMonad m, Element arr b) => arr b -> Int -> Int -> m (Mutable arr (PrimState m) b) Source #

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

unlift :: Contiguous arr => arr b -> ArrayArray# #

lift :: Contiguous arr => ArrayArray# -> arr b #

Synthetic Functions

singleton :: (Contiguous arr, Element arr a) => a -> arr a #

doubleton :: (Contiguous arr, Element arr a) => a -> a -> arr a #

tripleton :: (Contiguous arr, Element arr a) => a -> a -> a -> arr a #

append :: (Contiguous arr, Element arr a) => arr a -> arr a -> arr a #

map :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 c) => (b -> c) -> arr1 b -> arr2 c #

Map over the elements of an array.

map' :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 c) => (b -> c) -> arr1 b -> arr2 c #

Map strictly over the elements of an array.

imap :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 c) => (Int -> b -> c) -> arr1 b -> arr2 c #

Map over the elements of an array with the index.

foldr :: (Contiguous arr, Element arr a) => (a -> b -> b) -> b -> arr a -> b #

Right fold over the element of an array.

foldl' :: (Contiguous arr, Element arr a) => (b -> a -> b) -> b -> arr a -> b #

Strict left fold over the elements of an array.

foldr' :: (Contiguous arr, Element arr a) => (a -> b -> b) -> b -> arr a -> b #

Strict right fold over the elements of an array.

foldMap :: (Contiguous arr, Element arr a, Monoid m) => (a -> m) -> arr a -> m #

Monoidal fold over the element of an array.

foldMap' :: (Contiguous arr, Element arr a, Monoid m) => (a -> m) -> arr a -> m #

Strict monoidal fold over the elements of an array.

foldlM' :: (Contiguous arr, Element arr a, Monad m) => (b -> a -> m b) -> b -> arr a -> m b #

Strict left monadic fold over the elements of an array.

traverse :: (Contiguous arr, Element arr a, Element arr b, Applicative f) => (a -> f b) -> arr a -> f (arr b) #

traverse_ :: (Contiguous arr, Element arr a, Applicative f) => (a -> f b) -> arr a -> f () #

itraverse_ :: (Contiguous arr, Element arr a, Applicative f) => (Int -> a -> f b) -> arr a -> f () #

imapMutable' :: (PrimMonad m, Contiguous arr, Element arr a) => (Int -> a -> a) -> Mutable arr (PrimState m) a -> m () #

Strictly map over a mutable array with indices, modifying the elements in place.

traverseP :: (PrimMonad m, Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (a -> m b) -> arr1 a -> m (arr2 b) #

unsafeFromListN Source #

Arguments

:: (Contiguous arr, Element arr a) 
=> Int

length of list

-> [a]

list

-> arr a 

unsafeFromListReverseN Source #

Arguments

:: (Contiguous arr, Element arr a) 
=> Int

length of list

-> [a]

list

-> arr a 

liftHashWithSalt :: (Contiguous arr, Element arr a) => (Int -> a -> Int) -> Int -> arr a -> Int #

same :: Contiguous arr => arr a -> arr a -> Bool #

This function does not behave deterministically. Optimization level and inlining can affect its results. However, the one thing that can be counted on is that if it returns True, the two immutable arrays are definitely the same. This is useful as shortcut for equality tests. However, keep in mind that a result of False tells us nothing about the arguments.