PrimitiveArray-0.0.4.0: Unboxed, multidimensional arrays based on the primitive package.

Data.PrimitiveArray

Contents

Description

Unboxed, primitive, multidimensional tables. In instance for Ix-type keys comes with the package. This package trades safety for speed. The index operator (!) is basically the only function that does bounds-checking and only with an assertion. This, however, is by design. The only way to get an immutable table from a mutable one is by the unsafeFreezeM operation. Again, it is by design that both data structures share the same memory pointer internally.

TODO We kind-of lost all but the ST monad for monadic operations.

Synopsis

The PrimArray class.

class PrimArrayOps a b whereSource

Associated Types

data PrimArray a b :: *Source

PrimArray data type

Methods

unsafeIndexSource

Arguments

:: PrimArray a b 
-> a 
-> b

Index an array without bounds-checking

assocsSource

Arguments

:: PrimArray a b 
-> [(a, b)]

All associations of (key,value)

fromAssocsSource

Arguments

:: a 
-> a 
-> b 
-> [(a, b)] 
-> PrimArray a b

Pure build function

boundsSource

Arguments

:: PrimArray a b 
-> (a, a)

Min- and maxbound of all dimensions

checkBoundsSource

Arguments

:: PrimArray a b 
-> a 
-> Bool

Check if index is within bounds

fromListSource

Arguments

:: a 
-> a 
-> [b] 
-> PrimArray a b

Build the complete table from a list

toListSource

Arguments

:: PrimArray a b 
-> [b]

Read the complete table as a list

Instances

(Bounded a, Ix a, Prim b) => PrimArrayOps a b 

class PrimMonad s => PrimArrayOpsM a b s whereSource

Associated Types

data PrimArrayM a b s :: *Source

Monadic data type

Methods

readMSource

Arguments

:: PrimArrayM a b s 
-> a 
-> s b

Monadic read

writeMSource

Arguments

:: PrimArrayM a b s 
-> a 
-> b 
-> s ()

Monadic write

boundsMSource

Arguments

:: PrimArrayM a b s 
-> s (a, a)

Monadic bounds

fromAssocsMSource

Arguments

:: a 
-> a 
-> b 
-> [(a, b)] 
-> s (PrimArrayM a b s)

Build monadic array from assocs

unsafeFreezeMSource

Arguments

:: PrimArrayM a b s 
-> s (PrimArray a b)

UNSAFE freezing of array.

fromListMSource

Arguments

:: a 
-> a 
-> [b] 
-> s (PrimArrayM a b s)

Build the complete monadic table from a list

toListMSource

Arguments

:: PrimArrayM a b s 
-> s [b]

Read the complete monadic table as a list

Instances

(Bounded a, Ix a, Prim b) => PrimArrayOpsM a b (ST s) 

Helper functions.

(!) :: PrimArrayOps a b => PrimArray a b -> a -> bSource

Asserting unsafeIndex. Debug-code is checked for out-of-bounds occurances while production code uses unsafeIndex directly.

amap :: (PrimArrayOps a b, PrimArrayOps a c) => (b -> c) -> PrimArray a b -> PrimArray a cSource

Create a new array from an old one, mapping a function over all values.

Read and show instances