uvector-0.1.0.3: Fast unboxed arrays with a flexible interfaceSource codeContentsIndex
Data.Array.Vector
Contents
Array classes
The pure and mutable array types
Streaming pure arrays
Conversions to/from lists
Basic operations on pure arrays
Introducing and eliminating UArrs
Basic interface
Transforming UArrs
Reducing UArrs (folds)
Logical operations
Arithmetic operations
Building UArrs
Scans
Accumulating UArrs
Generating UArrs
Subarrays
Breaking arrays
Searching Arrays
Searching by equality
Searching with a predicate
Indexing UArr
Zipping and unzipping
Enumerations
Low level conversions
Low level conversions
Copying arrays
Packing CStrings and pointers
Using UArrs as CStrings
I/O with UArrs
Permutations
Searching
Arrays of pairs
Random arrays
I/O
Operations on mutable arrays
Strict pairs and sums
Injection and projection functions
Currying
Strict Maybe
Lazy wrapper
Class of hyperstrict types
Description
Synopsis
class UA e where
data UArr e
data MUArr 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)
streamU :: UA a => UArr a -> Stream a
unstreamU :: UA a => Stream a -> UArr a
toU :: UA e => [e] -> UArr e
fromU :: UA e => UArr e -> [e]
emptyU :: UA e => UArr e
singletonU :: UA e => e -> UArr e
consU :: UA e => e -> UArr e -> UArr e
snocU :: UA e => UArr e -> e -> UArr e
appendU :: UA e => UArr e -> UArr e -> UArr e
headU :: UA e => UArr e -> e
lastU :: UA e => UArr e -> e
tailU :: UA e => UArr e -> UArr e
initU :: UA e => UArr e -> UArr e
nullU :: UA e => UArr e -> Bool
unitsU :: Int -> UArr ()
lengthU :: UA e => UArr e -> Int
mapU :: (UA e, UA e') => (e -> e') -> UArr e -> UArr e'
foldU :: UA a => (a -> a -> a) -> a -> UArr a -> a
fold1U :: UA a => (a -> a -> a) -> UArr a -> a
fold1MaybeU :: UA a => (a -> a -> a) -> UArr a -> MaybeS a
foldlU :: UA a => (b -> a -> b) -> b -> UArr a -> b
foldl1U :: UA a => (a -> a -> a) -> UArr a -> a
foldl1MaybeU :: UA a => (a -> a -> a) -> UArr a -> MaybeS a
andU :: UArr Bool -> Bool
orU :: UArr Bool -> Bool
anyU :: UA e => (e -> Bool) -> UArr e -> Bool
allU :: UA e => (e -> Bool) -> UArr e -> Bool
sumU :: (Num e, UA e) => UArr e -> e
productU :: (Num e, UA e) => UArr e -> e
maximumU :: (Ord e, UA e) => UArr e -> e
minimumU :: (Ord e, UA e) => UArr e -> e
maximumByU :: UA e => (e -> e -> Ordering) -> UArr e -> e
minimumByU :: UA e => (e -> e -> Ordering) -> UArr e -> e
scanlU :: (UA a, UA b) => (b -> a -> b) -> b -> UArr a -> UArr b
scanl1U :: UA a => (a -> a -> a) -> UArr a -> UArr a
scanU :: UA a => (a -> a -> a) -> a -> UArr a -> UArr a
scan1U :: UA a => (a -> a -> a) -> UArr a -> UArr a
scanResU :: UA a => (a -> a -> a) -> a -> UArr a -> UArr a :*: a
mapAccumLU :: (UA a, UA b) => (c -> a -> c :*: b) -> c -> UArr a -> UArr b
replicateU :: UA e => Int -> e -> UArr e
replicateEachU :: UA e => Int -> UArr Int -> UArr e -> UArr e
takeU :: UA e => Int -> UArr e -> UArr e
dropU :: UA e => Int -> UArr e -> UArr e
splitAtU :: UA e => Int -> UArr e -> (UArr e, UArr e)
takeWhileU :: UA e => (e -> Bool) -> UArr e -> UArr e
dropWhileU :: UA e => (e -> Bool) -> UArr e -> UArr e
elemU :: (Eq e, UA e) => e -> UArr e -> Bool
notElemU :: (Eq e, UA e) => e -> UArr e -> Bool
filterU :: UA e => (e -> Bool) -> UArr e -> UArr e
findU :: UA a => (a -> Bool) -> UArr a -> Maybe a
indexU :: UA e => UArr e -> Int -> e
findIndexU :: UA a => (a -> Bool) -> UArr a -> Maybe Int
lookupU :: (Eq a, UA a, UA b) => a -> UArr (a :*: b) -> Maybe b
zipU :: (UA a, UA b) => UArr a -> UArr b -> UArr (a :*: b)
zip3U :: (UA e1, UA e2, UA e3) => UArr e1 -> UArr e2 -> UArr e3 -> UArr ((e1 :*: e2) :*: e3)
unzipU :: (UA a, UA b) => UArr (a :*: b) -> UArr a :*: UArr b
unzip3U :: (UA e1, UA e2, UA e3) => UArr ((e1 :*: e2) :*: e3) -> (UArr e1 :*: UArr e2) :*: UArr e3
zipWithU :: (UA a, UA b, UA c) => (a -> b -> c) -> UArr a -> UArr b -> UArr c
zipWith3U :: (UA a, UA b, UA c, UA d) => (a -> b -> c -> d) -> UArr a -> UArr b -> UArr c -> UArr d
fstU :: (UA a, UA b) => UArr (a :*: b) -> UArr a
sndU :: (UA a, UA b) => UArr (a :*: b) -> UArr b
enumFromToU :: (UA a, Integral a) => a -> a -> UArr a
enumFromToFracU :: (UA a, RealFrac a) => a -> a -> UArr a
enumFromThenToU :: Int -> Int -> Int -> UArr Int
enumFromStepLenU :: Int -> Int -> Int -> UArr Int
enumFromToEachU :: Int -> UArr (Int :*: Int) -> UArr Int
combineU :: UA a => UArr Bool -> UArr a -> UArr a -> UArr a
packU :: UA e => UArr e -> UArr Bool -> UArr e
indexedU :: UA e => UArr e -> UArr (Int :*: e)
repeatU :: UA e => Int -> UArr e -> UArr e
unfoldU :: UA a => Int -> (b -> MaybeS (a :*: b)) -> b -> UArr a
class UA a => UIO a where
hPutU :: Handle -> UArr a -> IO ()
hGetU :: Handle -> IO (UArr a)
newU :: UA e => Int -> (forall s. MUArr e s -> ST s ()) -> UArr e
unsafeFreezeAllMU :: UA e => MUArr e s -> ST s (UArr e)
permuteMU :: UA e => MUArr e s -> UArr e -> UArr Int -> ST s ()
atomicUpdateMU :: UA e => MUArr e s -> UArr (Int :*: e) -> ST s ()
unstreamMU :: UA a => MUArr a s -> Stream a -> ST s Int
data a :*: b = !a :*: !b
data EitherS a b
= LeftS !a
| RightS !b
fstS :: (a :*: b) -> a
sndS :: (a :*: b) -> b
pairS :: (a, b) -> a :*: b
unpairS :: (a :*: b) -> (a, b)
unsafe_pairS :: (a, b) -> a :*: b
unsafe_unpairS :: (a :*: b) -> (a, b)
curryS :: ((a :*: b) -> c) -> a -> b -> c
uncurryS :: (a -> b -> c) -> (a :*: b) -> c
data MaybeS a
= NothingS
| JustS !a
maybeS :: b -> (a -> b) -> MaybeS a -> b
fromMaybeS :: a -> MaybeS a -> a
Array classes
class UA e whereSource

Basic operations on representation types -----------------------------------------

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
data MUArr e :: * -> *Source
Methods
sliceU :: UArr e -> Int -> Int -> UArr eSource
Restrict access to a subrange of the original array (no copying)
lengthMU :: MUArr e s -> IntSource
Yield the length of a mutable unboxed array
newMU :: Int -> ST s (MUArr e s)Source
Allocate a mutable unboxed array
readMU :: MUArr e s -> Int -> ST s eSource
Read an element from a mutable unboxed array
writeMU :: MUArr e s -> Int -> e -> ST s ()Source
Update an element in a mutable unboxed array
copyMU :: MUArr e s -> Int -> UArr e -> ST s ()Source
Copy the contents of an immutable unboxed array into a mutable one from the specified position on
unsafeFreezeMU :: MUArr e s -> Int -> ST s (UArr e)Source
Convert a mutable into an immutable unboxed array
show/hide Instances
The pure and mutable array types
Streaming pure arrays
streamU :: UA a => UArr a -> Stream aSource
Generate a stream from an array, from left to right
unstreamU :: UA a => Stream a -> UArr aSource
Create an array from a stream, filling it from left to right
Conversions to/from lists
toU :: UA e => [e] -> UArr eSource

Conversion -----------

Turn a list into a parallel array

fromU :: UA e => UArr e -> [e]Source
Collect the elements of a parallel array in a list
Basic operations on pure arrays
Introducing and eliminating UArrs
emptyU :: UA e => UArr eSource
Yield an empty array
singletonU :: UA e => e -> UArr eSource
Yield a singleton array
Basic interface
consU :: UA e => e -> UArr e -> UArr eSource
Prepend an element to an array
snocU :: UA e => UArr e -> e -> UArr eSource
Append an element to an array
appendU :: UA e => UArr e -> UArr e -> UArr eSource
Concatenate two arrays
headU :: UA e => UArr e -> eSource
lastU :: UA e => UArr e -> eSource
tailU :: UA e => UArr e -> UArr eSource
initU :: UA e => UArr e -> UArr eSource
nullU :: UA e => UArr e -> BoolSource
Test whether the given array is empty
unitsU :: Int -> UArr ()Source

Basic operations on unboxed arrays -----------------------------------

Yield an array of units

lengthU :: UA e => UArr e -> IntSource
O(1), length returns the length of a UArr as an Int.
Transforming UArrs
mapU :: (UA e, UA e') => (e -> e') -> UArr e -> UArr e'Source
Map a function over an array
Reducing UArrs (folds)
foldU :: UA a => (a -> a -> a) -> a -> UArr a -> aSource
Array reduction that requires an associative combination function with its unit
fold1U :: UA a => (a -> a -> a) -> UArr a -> aSource
Reduction of a non-empty array which requires an associative combination function
fold1MaybeU :: UA a => (a -> a -> a) -> UArr a -> MaybeS aSource
foldlU :: UA a => (b -> a -> b) -> b -> UArr a -> bSource
Array reduction proceeding from the left
foldl1U :: UA a => (a -> a -> a) -> UArr a -> aSource

Array reduction proceeding from the left for non-empty arrays

FIXME: Rewrite for Streams.

foldl1U :: UA a => (a -> a -> a) -> UArr a -> a {--} foldl1U f arr = checkNotEmpty (here foldl1U) (lengthU arr) $ foldlU f (arr indexU 0) (sliceU arr 1 (lengthU arr - 1))

foldl1MaybeU :: UA a => (a -> a -> a) -> UArr a -> MaybeS aSource
Logical operations
andU :: UArr Bool -> BoolSource
orU :: UArr Bool -> BoolSource
anyU :: UA e => (e -> Bool) -> UArr e -> BoolSource
allU :: UA e => (e -> Bool) -> UArr e -> BoolSource
Arithmetic operations
sumU :: (Num e, UA e) => UArr e -> eSource
Compute the sum of an array of numerals
productU :: (Num e, UA e) => UArr e -> eSource
Compute the product of an array of numerals
maximumU :: (Ord e, UA e) => UArr e -> eSource
Determine the maximum element in an array
minimumU :: (Ord e, UA e) => UArr e -> eSource
Determine the minimum element in an array
maximumByU :: UA e => (e -> e -> Ordering) -> UArr e -> eSource
Determine the maximum element in an array under the given ordering
minimumByU :: UA e => (e -> e -> Ordering) -> UArr e -> eSource
Determine the minimum element in an array under the given ordering
Building UArrs
Scans
scanlU :: (UA a, UA b) => (b -> a -> b) -> b -> UArr a -> UArr bSource
Prefix scan proceedings from left to right
scanl1U :: UA a => (a -> a -> a) -> UArr a -> UArr aSource
Prefix scan of a non-empty array proceeding from left to right
scanU :: UA a => (a -> a -> a) -> a -> UArr a -> UArr aSource
Prefix scan proceeding from left to right that needs an associative combination function with its unit
scan1U :: UA a => (a -> a -> a) -> UArr a -> UArr aSource
Prefix scan of a non-empty array proceeding from left to right that needs an associative combination function
scanResU :: UA a => (a -> a -> a) -> a -> UArr a -> UArr a :*: aSource
Accumulating UArrs
mapAccumLU :: (UA a, UA b) => (c -> a -> c :*: b) -> c -> UArr a -> UArr bSource

Accumulating map from left to right. Does not return the accumulator.

FIXME: Naming inconsistent with lists.

Generating UArrs
replicateU :: UA e => Int -> e -> UArr eSource
Yield an array where all elements contain the same value
replicateEachU :: UA e => Int -> UArr Int -> UArr e -> UArr eSource
Subarrays
Breaking arrays
takeU :: UA e => Int -> UArr e -> UArr eSource
dropU :: UA e => Int -> UArr e -> UArr eSource
splitAtU :: UA e => Int -> UArr e -> (UArr e, UArr e)Source
Split an array into two halves at the given index
takeWhileU :: UA e => (e -> Bool) -> UArr e -> UArr eSource
takeWhile, applied to a predicate p and a UArr xs, returns the longest prefix (possibly empty) of xs of elements that satisfy p.
dropWhileU :: UA e => (e -> Bool) -> UArr e -> UArr eSource
dropWhile p xs returns the suffix remaining after takeWhile p xs.
Searching Arrays
Searching by equality
elemU :: (Eq e, UA e) => e -> UArr e -> BoolSource
Determine whether the given element is in an array
notElemU :: (Eq e, UA e) => e -> UArr e -> BoolSource
Negation of elemU
Searching with a predicate
filterU :: UA e => (e -> Bool) -> UArr e -> UArr eSource
Extract all elements from an array that meet the given predicate
findU :: UA a => (a -> Bool) -> UArr a -> Maybe aSource
O(n),fusion. The find function takes a predicate and an array and returns the first element in the list matching the predicate, or Nothing if there is no such element.
Indexing UArr
indexU :: UA e => UArr e -> Int -> eSource
Array indexing
findIndexU :: UA a => (a -> Bool) -> UArr a -> Maybe IntSource
O(n), fusion, The findIndex function takes a predicate and an array and returns the index of the first element in the array satisfying the predicate, or Nothing if there is no such element.
lookupU :: (Eq a, UA a, UA b) => a -> UArr (a :*: b) -> Maybe bSource
O(n),fusion. lookup key assocs looks up a key in an array of pairs treated as an association table.
Zipping and unzipping
zipU :: (UA a, UA b) => UArr a -> UArr b -> UArr (a :*: b)Source
Elementwise pairing of array elements.
zip3U :: (UA e1, UA e2, UA e3) => UArr e1 -> UArr e2 -> UArr e3 -> UArr ((e1 :*: e2) :*: e3)Source
unzipU :: (UA a, UA b) => UArr (a :*: b) -> UArr a :*: UArr bSource
Elementwise unpairing of array elements.
unzip3U :: (UA e1, UA e2, UA e3) => UArr ((e1 :*: e2) :*: e3) -> (UArr e1 :*: UArr e2) :*: UArr e3Source
zipWithU :: (UA a, UA b, UA c) => (a -> b -> c) -> UArr a -> UArr b -> UArr cSource
zipWith3U :: (UA a, UA b, UA c, UA d) => (a -> b -> c -> d) -> UArr a -> UArr b -> UArr c -> UArr dSource
fstU :: (UA a, UA b) => UArr (a :*: b) -> UArr aSource
Yield the first components of an array of pairs.
sndU :: (UA a, UA b) => UArr (a :*: b) -> UArr bSource
Yield the second components of an array of pairs.
Enumerations
enumFromToU :: (UA a, Integral a) => a -> a -> UArr aSource

Yield an enumerated array

FIXME: See comments about enumFromThenToS

enumFromToFracU :: (UA a, RealFrac a) => a -> a -> UArr aSource
enumFromThenToU :: Int -> Int -> Int -> UArr IntSource

Yield an enumerated array using a specific step

FIXME: See comments about enumFromThenToS

enumFromStepLenU :: Int -> Int -> Int -> UArr IntSource
enumFromToEachU :: Int -> UArr (Int :*: Int) -> UArr IntSource
Low level conversions
Low level conversions
Copying arrays
Packing CStrings and pointers
Using UArrs as CStrings
I/O with UArrs
combineU :: UA a => UArr Bool -> UArr a -> UArr a -> UArr aSource
packU :: UA e => UArr e -> UArr Bool -> UArr eSource
Extract all elements from an array according to a given flag array
indexedU :: UA e => UArr e -> UArr (Int :*: e)Source

Indexing ---------

Associate each element of the array with its index

repeatU :: UA e => Int -> UArr e -> UArr eSource
Repeat an array n times
Permutations
Searching
Arrays of pairs
Random arrays
unfoldU :: UA a => Int -> (b -> MaybeS (a :*: b)) -> b -> UArr aSource
I/O
class UA a => UIO a whereSource
Methods
hPutU :: Handle -> UArr a -> IO ()Source
hGetU :: Handle -> IO (UArr a)Source
show/hide Instances
Operations on mutable arrays
newU :: UA e => Int -> (forall s. MUArr e s -> ST s ()) -> UArr eSource
Creating unboxed arrays ------------------------
unsafeFreezeAllMU :: UA e => MUArr e s -> ST s (UArr e)Source
permuteMU :: UA e => MUArr e s -> UArr e -> UArr Int -> ST s ()Source
Permutations -------------
atomicUpdateMU :: UA e => MUArr e s -> UArr (Int :*: e) -> ST s ()Source
unstreamMU :: UA a => MUArr a s -> Stream a -> ST s IntSource
Fill a mutable array from a stream from left to right and yield the number of elements written.
Strict pairs and sums
data a :*: b Source
Strict pair
Constructors
!a :*: !b
show/hide Instances
(Eq a, Eq b) => Eq (a :*: b)
(Ord a, Ord b) => Ord (a :*: b)
(Read a, Read b) => Read (a :*: b)
(Show a, Show b) => Show (a :*: b)
(UIO a, UIO b) => UIO (a :*: b)
(UA a, UA b) => UA (a :*: b)
data EitherS a b Source
Strict sum
Constructors
LeftS !a
RightS !b
Injection and projection functions
fstS :: (a :*: b) -> aSource
sndS :: (a :*: b) -> bSource
pairS :: (a, b) -> a :*: bSource
unpairS :: (a :*: b) -> (a, b)Source
unsafe_pairS :: (a, b) -> a :*: bSource
unsafe_unpairS :: (a :*: b) -> (a, b)Source
Currying
curryS :: ((a :*: b) -> c) -> a -> b -> cSource
uncurryS :: (a -> b -> c) -> (a :*: b) -> cSource
Strict Maybe
data MaybeS a Source
Strict Maybe
Constructors
NothingS
JustS !a
show/hide Instances
maybeS :: b -> (a -> b) -> MaybeS a -> bSource
fromMaybeS :: a -> MaybeS a -> aSource
Lazy wrapper
Class of hyperstrict types
Produced by Haddock version 2.4.2