Defines the extra types we use when representing algebraic data in parallel arrays. We don't store values of user defined algebraic type directly in PArrays. Instead, we convert these to a generic representation and store that representation.
Conversion to and from the generic representation is handled by the methods of the PA class defined in Data.Array.Parallel.PArray.PRepr.
The Void type
Void type is used when representing enumerations.
A type like Bool is represented as
Sum2 Void Void, meaning that we only
only care about the tag of the data constructor and not its argumnent.
Sum types used for the generic representation of algebraic data.
The Wrap type
When converting a data type to its generic representation, we use
Wrap to help us convert only one layer at a time. For example:
data Foo a = Foo Int a instance PA a => PA (Foo a) where type PRepr (Foo a) = (Int, Wrap a) -- define how (Foo a) is represented
Here we've converted the
Foo data constructor to a pair, and Int
is its own representation type. We have PData/PR instances for pairs and
Ints, so we can work with arrays of these types. However, we can't just
use (Int, a) as the representation of (Foo a) because
be user defined and we won't have PData/PR instances for it.
Instead, we wrap the second element with the Wrap constructor, which tells us that if we want to process this element we still need to convert it to the generic representation (and back). This last part is done by the PR instance of Wrap, who's methods are defined by calls to the *PD functions from Data.Array.Parallel.PArray.PRepr.