uvector-0.1.0.4: Fast unboxed arrays with a flexible interfaceSource codeContentsIndex
Data.Array.Vector.UArr
Portabilitynon-portable (GADTS)
Stabilityinternal
MaintainerRoman Leshchinskiy <rl@cse.unsw.edu.au>
Contents
Array types and classes containing the admissable elements types
Basic operations on parallel arrays
I/O
Description

Description --------------------------------------------------------------- This module defines unlifted arrays generically as a GADT.

Slicing is implemented by each BUArr having the slicing information. A possible alternative design would be to maintain this information in UArr, but not in the representations, but at the root. This may seem attractive at first, but seems to be more disruptive without any real benefits _ this is essentially, because we then need the slicing information at each level; ie, also at the leafs where it is sufficient using the current implementation.

Todo ----------------------------------------------------------------------

Synopsis
class UA e where
data UArr e
data MUArr e :: * -> *
lengthU :: UArr e -> Int
indexU :: UArr e -> Int -> e
sliceU :: UArr e -> Int -> Int -> UArr e
lengthMU :: MUArr e s -> Int
newMU :: Int -> ST s (MUArr e s)
readMU :: MUArr e s -> Int -> ST s e
writeMU :: MUArr e s -> Int -> e -> ST s ()
copyMU :: MUArr e s -> Int -> UArr e -> ST s ()
unsafeFreezeMU :: MUArr e s -> Int -> ST s (UArr e)
memcpyMU :: MUArr e s -> MUArr e s -> Int -> ST s ()
memcpyOffMU :: MUArr e s -> MUArr e s -> Int -> Int -> Int -> ST s ()
memmoveOffMU :: MUArr e s -> MUArr e s -> Int -> Int -> Int -> ST s ()
class UAE e => UPrim e where
mkUAPrim :: BUArr e -> UArr e
unUAPrim :: UArr e -> BUArr e
mkMUAPrim :: MBUArr s e -> MUArr e s
unMUAPrim :: MUArr e s -> MBUArr s e
unitsU :: Int -> UArr ()
zipU :: (UA a, UA b) => UArr a -> UArr b -> UArr (a :*: b)
unzipU :: (UA a, UA b) => UArr (a :*: b) -> UArr a :*: UArr b
fstU :: (UA a, UA b) => UArr (a :*: b) -> UArr a
sndU :: (UA a, UA b) => UArr (a :*: b) -> UArr b
newU :: UA e => Int -> (forall s. MUArr e s -> ST s ()) -> UArr e
newDynU :: UA e => Int -> (forall s. MUArr e s -> ST s Int) -> UArr e
newDynResU :: UA e => Int -> (forall s. MUArr e s -> ST s (Int :*: r)) -> UArr e :*: r
unsafeFreezeAllMU :: UA e => MUArr e s -> ST s (UArr e)
unsafeZipMU :: (UA a, UA b) => MUArr a s -> MUArr b s -> MUArr (a :*: b) s
unsafeUnzipMU :: (UA a, UA b) => MUArr (a :*: b) s -> MUArr a s :*: MUArr b s
class UA a => UIO a where
hPutU :: Handle -> UArr a -> IO ()
hGetU :: Handle -> IO (UArr a)
Array types and classes containing the admissable elements types
class UA e whereSource
This type class determines the types that can be elements immutable unboxed arrays. The representation type of these arrays is defined by way of an associated type. All representation-dependent functions are methods of this class.
Associated Types
data UArr e Source
The basic array datatype.
data MUArr e :: * -> *Source
Methods
lengthU :: UArr e -> IntSource
O(1?). Yield the length of an unboxed array.
indexU :: UArr e -> Int -> eSource
sliceU :: UArr e -> Int -> Int -> UArr eSource
O(1). sliceU restricts access to a subrange of the original array (no copying).
lengthMU :: MUArr e s -> IntSource
O(1). lengthMU yields the length of a mutable unboxed array.
newMU :: Int -> ST s (MUArr e s)Source
O(1). newMU allocates a mutable unboxed array of the specified length.
readMU :: MUArr e s -> Int -> ST s eSource
O(1). readMU reads the element at the specified index of a mutable unboxed array.
writeMU :: MUArr e s -> Int -> e -> ST s ()Source
O(1). writeMU writes a new value to the specified index of a mutable unboxed array.
copyMU :: MUArr e s -> Int -> UArr e -> ST s ()Source
O(n). copyMU copies the contents of an immutable unboxed array into a mutable one starting from the specified index.
unsafeFreezeMU :: MUArr e s -> Int -> ST s (UArr e)Source
O(1). unsafeFreezeMU converts a prefix of a mutable array into an immutable unboxed array, without copying. The mutable array must not be mutated after this.
memcpyMU :: MUArr e s -> MUArr e s -> Int -> ST s ()Source
Copy a portion of one mutable array to a second.
memcpyOffMU :: MUArr e s -> MUArr e s -> Int -> Int -> Int -> ST s ()Source
Copy a portion of one mutable array to a second, beginning at the specified offsets for each.
memmoveOffMU :: MUArr e s -> MUArr e s -> Int -> Int -> Int -> ST s ()Source
Copy a portion of one mutable array to a second, beginning at the specified offsets for each. This operation is safe even if the source and destination are the same.
show/hide Instances
class UAE e => UPrim e whereSource
Methods
mkUAPrim :: BUArr e -> UArr eSource
unUAPrim :: UArr e -> BUArr eSource
mkMUAPrim :: MBUArr s e -> MUArr e sSource
unMUAPrim :: MUArr e s -> MBUArr s eSource
show/hide Instances
Basic operations on parallel arrays
unitsU :: Int -> UArr ()Source
O(1). Yield an array of units.
zipU :: (UA a, UA b) => UArr a -> UArr b -> UArr (a :*: b)Source

O(1). Elementwise pairing of array elements.

N.B: The output will be as long as the first array (and will thus access past the end of the second array), unlike its List counterpart. This will not occur at the time zipU is called, but only after the resulting array is accessed.

unzipU :: (UA a, UA b) => UArr (a :*: b) -> UArr a :*: UArr bSource
O(1). Elementwise unpairing of array elements.
fstU :: (UA a, UA b) => UArr (a :*: b) -> UArr aSource
O(1). Yield the first components of an array of pairs.
sndU :: (UA a, UA b) => UArr (a :*: b) -> UArr bSource
O(1). Yield the second components of an array of pairs.
newU :: UA e => Int -> (forall s. MUArr e s -> ST s ()) -> UArr eSource
O(n). newU constructs an immutable array of the given size by performing the provided initialization function on a mutable representation of the output array.
newDynU :: UA e => Int -> (forall s. MUArr e s -> ST s Int) -> UArr eSource
newDynResU :: UA e => Int -> (forall s. MUArr e s -> ST s (Int :*: r)) -> UArr e :*: rSource
unsafeFreezeAllMU :: UA e => MUArr e s -> ST s (UArr e)Source
O(1). unsafeFreezeAllMU converts an entire mutable array into an immutable array, without copying. The mutable array must not be mutated after this.
unsafeZipMU :: (UA a, UA b) => MUArr a s -> MUArr b s -> MUArr (a :*: b) sSource
Elementwise pairing of mutable arrays. This is an unsafe operation, as no copying is performed, so changes to the pair array will affect the original arrays, and vice versa.
unsafeUnzipMU :: (UA a, UA b) => MUArr (a :*: b) s -> MUArr a s :*: MUArr b sSource
Elementwise unpairing of mutable arrays. This is an unsafe operation, as no copying is performed, so changes to the unpaired arrays will affect the original, and vice versa.
I/O
class UA a => UIO a whereSource
Methods
hPutU :: Handle -> UArr a -> IO ()Source
hGetU :: Handle -> IO (UArr a)Source
show/hide Instances
Produced by Haddock version 2.4.2