Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data family DataFrame (t :: l) (xs :: [k])
- data SomeDataFrame (t :: l) = (Dimensions ns, ArraySingletons t ns) => SomeDataFrame (DataFrame t ns)
- data DataFrame' (xs :: [k]) (t :: l)
- pattern (:*:) :: forall (xs :: [Type]) (ns :: [Nat]). forall (y :: Type) (ys :: [Type]). xs ~ (y ': ys) => DataFrame y ns -> DataFrame ys ns -> DataFrame xs ns
- pattern Z :: forall (xs :: [Type]) (ns :: [Nat]). xs ~ '[] => DataFrame xs ns
- type family AllTypes (f :: Type -> Constraint) (ts :: l) :: Constraint where ...
- type family ImplAllows (f :: Type -> Constraint) (ts :: l) (ds :: [Nat]) :: Constraint where ...
- type family ArraySingletons (ts :: l) (ns :: [Nat]) :: Constraint where ...
- type family PrimFrames (ts :: l) (ns :: [Nat]) :: Constraint where ...
- class DataFrameInference (t :: l) where
- inferOrd :: forall t ds. (Ord t, ArraySingleton t ds) => DataFrame t ds -> Evidence (Ord (DataFrame t ds))
- inferNum :: forall t ds. (Num t, ArraySingletons t ds) => DataFrame t ds -> Evidence (Num (DataFrame t ds))
- inferFractional :: forall t ds. (Fractional t, ArraySingleton t ds) => DataFrame t ds -> Evidence (Fractional (DataFrame t ds))
- inferFloating :: forall t ds. (Floating t, ArraySingleton t ds) => DataFrame t ds -> Evidence (Floating (DataFrame t ds))
- inferOrd' :: forall t ds. (Ord t, ArraySingleton t ds) => Evidence (Ord (DataFrame t ds))
- inferNum' :: forall t ds. (Num t, ArraySingletons t ds) => Evidence (Num (DataFrame t ds))
- inferFractional' :: forall t ds. (Fractional t, ArraySingleton t ds) => Evidence (Fractional (DataFrame t ds))
- inferFloating' :: forall t ds. (Floating t, ArraySingleton t ds) => Evidence (Floating (DataFrame t ds))
- inferASing' :: forall t ds. (DataFrameInference t, AllTypes PrimBytes t, Dimensions ds) => Evidence (ArraySingletons t ds)
- inferEq' :: forall t ds. (DataFrameInference t, AllTypes Eq t, ArraySingletons t ds) => Evidence (Eq (DataFrame t ds))
- inferShow' :: forall t ds. (DataFrameInference t, AllTypes Show t, ArraySingletons t ds, Dimensions ds) => Evidence (Show (DataFrame t ds))
- inferPrim' :: forall t ds. (DataFrameInference t, AllTypes PrimBytes t, ArraySingletons t ds, Dimensions ds) => Evidence (PrimFrames t ds)
- inferPrimElem' :: forall t ds. (DataFrameInference t, ArraySingletons t ds, ds ~ (Head ds ': Tail ds)) => Evidence (AllTypes PrimBytes t)
- ixOff :: PrimArray t a => Int -> a -> t
- unsafeFromFlatList :: PrimArray t a => Int -> [t] -> a
- class Dim1 (t :: [k] -> Type) (ds :: [k]) where
- class Dim2 (t :: [k] -> Type) (ds :: [k]) where
- class Dim3 (t :: [k] -> Type) (ds :: [k]) where
- dimSize1 :: Dim1 t ds => t ds -> Word
- dimSize2 :: Dim2 t ds => t ds -> Word
- dimSize3 :: Dim3 t ds => t ds -> Word
- bSizeOf :: PrimBytes a => a -> Int
- bAlignOf :: PrimBytes a => a -> Int
- data Dim k (x :: k) :: forall k. k -> * where
- pattern Dim :: forall k (n :: k). () => KnownDim k n => Dim k n
- pattern D :: forall (n :: Nat). () => KnownDim Nat n => Dim Nat n
- pattern Dn :: forall (xn :: XNat). KnownXNatType xn => forall (n :: Nat). (KnownDim Nat n, (~) XNat xn (N n)) => Dim Nat n -> Dim XNat xn
- pattern Dx :: forall (xn :: XNat). KnownXNatType xn => forall (n :: Nat) (m :: Nat). (KnownDim Nat n, MinDim m n, (~) XNat xn (XN m)) => Dim Nat n -> Dim XNat xn
- newtype Idx k (n :: k) :: forall k. k -> * = Idx {}
- data XNat :: *
- type Dims k (xs :: [k]) = TypedList k (Dim k) xs
- type Idxs k (xs :: [k]) = TypedList k (Idx k) xs
- data TypedList k (f :: k -> Type) (xs :: [k]) :: forall k. (k -> Type) -> [k] -> * where
- pattern U :: forall k (f :: k -> Type) (xs :: [k]). () => (~) [k] xs ([] k) => TypedList k f xs
- pattern (:*) :: forall k (f :: k -> Type) (xs :: [k]). () => forall (y :: k) (ys :: [k]). (~) [k] xs ((:) k y ys) => f y -> TypedList k f ys -> TypedList k f xs
- pattern Empty :: forall k (f :: k -> Type) (xs :: [k]). () => (~) [k] xs ([] k) => TypedList k f xs
- pattern TypeList :: forall k (xs :: [k]). () => RepresentableList k xs => TypeList k xs
- pattern Cons :: forall k (f :: k -> Type) (xs :: [k]). () => forall (y :: k) (ys :: [k]). (~) [k] xs ((:) k y ys) => f y -> TypedList k f ys -> TypedList k f xs
- pattern Snoc :: forall k (f :: k -> Type) (xs :: [k]). () => forall (sy :: [k]) (y :: k). (~) [k] xs ((+:) k sy y) => TypedList k f sy -> f y -> TypedList k f xs
- pattern Reverse :: forall k (f :: k -> Type) (xs :: [k]). () => forall (sx :: [k]). ((~) [k] xs (Reverse k sx), (~) [k] sx (Reverse k xs)) => TypedList k f sx -> TypedList k f xs
Data types
data family DataFrame (t :: l) (xs :: [k]) Source #
Keep data in a primitive data frame and maintain information about Dimensions in the type system
Dim3 XNat (DataFrame l1 XNat l2) ((:) XNat d1 ((:) XNat d2 ((:) XNat d3 ds))) Source # | |
Dim2 XNat (DataFrame l1 XNat l2) ((:) XNat d1 ((:) XNat d2 ds)) Source # | |
Dim1 XNat (DataFrame l1 XNat l2) ((:) XNat d ds) Source # | |
data DataFrame Type Nat Source # | Single frame |
data DataFrame l XNat Source # | Data frame with some dimensions missing at compile time. Pattern-match against its constructor to get a Nat-indexed data frame. |
data DataFrame [Type] Nat Source # | Multiple "columns" of data frames of the same shape |
data SomeDataFrame (t :: l) Source #
Data frame that has an unknown dimensionality at compile time. Pattern-match against its constructor to get a Nat-indexed data frame
(Dimensions ns, ArraySingletons t ns) => SomeDataFrame (DataFrame t ns) |
(AllTypes l Eq t, DataFrameInference l t) => Eq (SomeDataFrame l t) Source # | |
(AllTypes l Show t, DataFrameInference l t) => Show (SomeDataFrame l t) Source # | |
data DataFrame' (xs :: [k]) (t :: l) Source #
DataFrame with its type arguments swapped.
pattern (:*:) :: forall (xs :: [Type]) (ns :: [Nat]). forall (y :: Type) (ys :: [Type]). xs ~ (y ': ys) => DataFrame y ns -> DataFrame ys ns -> DataFrame xs ns infixr 6 Source #
Constructing a MultiFrame
using DataFrame columns
pattern Z :: forall (xs :: [Type]) (ns :: [Nat]). xs ~ '[] => DataFrame xs ns Source #
Empty MultiFrame
Infer type class instances
type family AllTypes (f :: Type -> Constraint) (ts :: l) :: Constraint where ... Source #
type family ImplAllows (f :: Type -> Constraint) (ts :: l) (ds :: [Nat]) :: Constraint where ... Source #
ImplAllows f (t :: Type) ds = f (Array t ds) | |
ImplAllows _ ('[] :: [Type]) _ = () | |
ImplAllows f (t ': ts :: [Type]) ds = (f (Array t ds), ImplAllows f ts ds) |
type family ArraySingletons (ts :: l) (ns :: [Nat]) :: Constraint where ... Source #
ArraySingletons (t :: Type) ns = ArraySingleton t ns | |
ArraySingletons ('[] :: [Type]) _ = () | |
ArraySingletons (t ': ts :: [Type]) ns = (ArraySingleton t ns, ArraySingletons ts ns) |
type family PrimFrames (ts :: l) (ns :: [Nat]) :: Constraint where ... Source #
PrimFrames (t :: Type) ns = (PrimBytes (DataFrame t ns), PrimArray t (DataFrame t ns)) | |
PrimFrames ('[] :: [Type]) _ = () | |
PrimFrames (t ': ts :: [Type]) ns = (PrimBytes (DataFrame t ns), PrimArray t (DataFrame t ns), PrimFrames ts ns) |
class DataFrameInference (t :: l) where Source #
inferASing :: (AllTypes PrimBytes t, Dimensions ds) => DataFrame t ds -> Evidence (ArraySingletons t ds) Source #
Bring an evidence of ArraySingleton
instance into
a scope at runtime.
This is often used to let GHC infer other complex type class instances,
such as SubSpace
.
inferEq :: (AllTypes Eq t, ArraySingletons t ds) => DataFrame t ds -> Evidence (Eq (DataFrame t ds)) Source #
inferShow :: (AllTypes Show t, ArraySingletons t ds, Dimensions ds) => DataFrame t ds -> Evidence (Show (DataFrame t ds)) Source #
inferPrim :: (AllTypes PrimBytes t, ArraySingletons t ds, Dimensions ds) => DataFrame t ds -> Evidence (PrimFrames t ds) Source #
inferPrimElem :: (ArraySingletons t ds, ds ~ (Head ds ': Tail ds)) => DataFrame t ds -> Evidence (AllTypes PrimBytes t) Source #
This is a special function, because Scalar does not require PrimBytes. That is why the dimension list in the argument nust not be empty.
DataFrameInference Type t Source # | |
RepresentableList Type ts => DataFrameInference [Type] ts Source # | |
inferOrd :: forall t ds. (Ord t, ArraySingleton t ds) => DataFrame t ds -> Evidence (Ord (DataFrame t ds)) Source #
inferNum :: forall t ds. (Num t, ArraySingletons t ds) => DataFrame t ds -> Evidence (Num (DataFrame t ds)) Source #
inferFractional :: forall t ds. (Fractional t, ArraySingleton t ds) => DataFrame t ds -> Evidence (Fractional (DataFrame t ds)) Source #
inferFloating :: forall t ds. (Floating t, ArraySingleton t ds) => DataFrame t ds -> Evidence (Floating (DataFrame t ds)) Source #
inferFractional' :: forall t ds. (Fractional t, ArraySingleton t ds) => Evidence (Fractional (DataFrame t ds)) Source #
inferFloating' :: forall t ds. (Floating t, ArraySingleton t ds) => Evidence (Floating (DataFrame t ds)) Source #
inferASing' :: forall t ds. (DataFrameInference t, AllTypes PrimBytes t, Dimensions ds) => Evidence (ArraySingletons t ds) Source #
inferEq' :: forall t ds. (DataFrameInference t, AllTypes Eq t, ArraySingletons t ds) => Evidence (Eq (DataFrame t ds)) Source #
inferShow' :: forall t ds. (DataFrameInference t, AllTypes Show t, ArraySingletons t ds, Dimensions ds) => Evidence (Show (DataFrame t ds)) Source #
inferPrim' :: forall t ds. (DataFrameInference t, AllTypes PrimBytes t, ArraySingletons t ds, Dimensions ds) => Evidence (PrimFrames t ds) Source #
inferPrimElem' :: forall t ds. (DataFrameInference t, ArraySingletons t ds, ds ~ (Head ds ': Tail ds)) => Evidence (AllTypes PrimBytes t) Source #
Misc
unsafeFromFlatList :: PrimArray t a => Int -> [t] -> a Source #
Construct an array from a flat list and length
Re-exports from dimensions
data Dim k (x :: k) :: forall k. k -> * where #
Singleton type to store type-level dimension value.
On the one hand, it can be used to let type-inference system know
relations between type-level naturals.
On the other hand, this is just a newtype wrapper on the Word
type.
Usually, the type parameter of Dim
is either Nat
or XNat
.
If dimensionality of your data is known in advance, use Nat
;
if you know the size of some dimensions, but do not know the size
of others, use XNat
s to represent them.
pattern Dim :: forall k (n :: k). () => KnownDim k n => Dim k n | Independently of the kind of type-level number,
construct an instance of Match against this pattern to bring |
pattern D :: forall (n :: Nat). () => KnownDim Nat n => Dim Nat n | Same as |
pattern Dn :: forall (xn :: XNat). KnownXNatType xn => forall (n :: Nat). (KnownDim Nat n, (~) XNat xn (N n)) => Dim Nat n -> Dim XNat xn | Statically known |
pattern Dx :: forall (xn :: XNat). KnownXNatType xn => forall (n :: Nat) (m :: Nat). (KnownDim Nat n, MinDim m n, (~) XNat xn (XN m)) => Dim Nat n -> Dim XNat xn |
|
Dim3 k (TypedList k (Dim k)) ((:) k d1 ((:) k d2 ((:) k d3 ds))) Source # | |
Dim2 k (TypedList k (Dim k)) ((:) k d1 ((:) k d2 ds)) Source # | |
Dim1 k (TypedList k (Dim k)) ((:) k d ds) Source # | |
Eq (Dim Nat n) | |
Eq (Dim XNat x) | |
Ord (Dim Nat n) | |
Ord (Dim XNat x) | |
KnownDim Nat m => Read (Dim XNat (XN m)) | |
Show (Dim k x) | |
newtype Idx k (n :: k) :: forall k. k -> * #
This type is used to index a single dimension;
the range of indices is from 1
to n
.
Note, this type has a weird Enum
instance:
>>>
fromEnum (Idx 7)
6
The logic behind this is that the Enum
class is used to transform
indices to offsets. That is, element of an array at index k :: Idx n
is the element taken by an offset `k - 1 :: Int`.
Generic1 k (Idx k) | |
KnownDim k n => Bounded (Idx k n) | |
Dimensions k ds => Bounded (Idxs k ds) | |
KnownDim k n => Enum (Idx k n) | |
Dimensions k ds => Enum (Idxs k ds) | |
Eq (Idx k n) | |
Eq (Idxs k xs) | |
KnownDim k n => Integral (Idx k n) | |
(Typeable * k, Typeable k n) => Data (Idx k n) | |
KnownDim k n => Num (Idx k n) | |
KnownDim k n => Num (Idxs k ((:) k n ([] k))) | With this instance we can slightly reduce indexing expressions, e.g. x ! (1 :* 2 :* 4) == x ! (1 :* 2 :* 4 :* U) |
Ord (Idx k n) | |
Ord (Idxs k xs) | Compare indices by their importance in lexicorgaphic order
from the last dimension to the first dimension
(the last dimension is the most significant one) Literally, compare a b = compare (reverse $ listIdxs a) (reverse $ listIdxs b) This is the same sort == sortOn fromEnum |
Read (Idx k n) | |
KnownDim k n => Real (Idx k n) | |
Show (Idx k n) | |
Show (Idxs k xs) | |
Generic (Idx k n) | |
Storable (Idx k n) | |
PrimBytes (Idx * x) Source # | |
RepresentableList * xs => PrimBytes (Idxs * xs) Source # | |
type Rep1 k (Idx k) | |
type Rep (Idx k n) | |
Either known or unknown at compile-time natural number
KnownDimKind XNat | |
DataFrameToList XNat t xns xz Source # | |
KnownDim Nat n => KnownDim XNat (N n) | |
Dim3 XNat (DataFrame l1 XNat l2) ((:) XNat d1 ((:) XNat d2 ((:) XNat d3 ds))) Source # | |
Dim2 XNat (DataFrame l1 XNat l2) ((:) XNat d1 ((:) XNat d2 ds)) Source # | |
Dim1 XNat (DataFrame l1 XNat l2) ((:) XNat d ds) Source # | |
Eq (Dim XNat x) | |
Ord (Dim XNat x) | |
KnownDim Nat m => Read (Dim XNat (XN m)) | |
data STDataFrame XNat Source # | Data frame with some dimensions missing at compile time. Pattern-match against its constructor to get a Nat-indexed mutable data frame. |
data IODataFrame XNat Source # | Data frame with some dimensions missing at compile time. Pattern-match against its constructor to get a Nat-indexed mutable data frame. |
data DataFrame l XNat Source # | Data frame with some dimensions missing at compile time. Pattern-match against its constructor to get a Nat-indexed data frame. |
type Idxs k (xs :: [k]) = TypedList k (Idx k) xs #
Type-level dimensional indexing with arbitrary Word values inside.
Most of the operations on it require Dimensions
constraint,
because the Idxs
itself does not store info about dimension bounds.
Note, this type has a special Enum
instance:
fromEnum
gives an offset of the index in a flat 1D array;
this is in line with a weird Enum
instance of Idx
type.
data TypedList k (f :: k -> Type) (xs :: [k]) :: forall k. (k -> Type) -> [k] -> * where #
Type-indexed list
pattern U :: forall k (f :: k -> Type) (xs :: [k]). () => (~) [k] xs ([] k) => TypedList k f xs | Zero-length type list |
pattern (:*) :: forall k (f :: k -> Type) (xs :: [k]). () => forall (y :: k) (ys :: [k]). (~) [k] xs ((:) k y ys) => f y -> TypedList k f ys -> TypedList k f xs infixr 5 | Constructing a type-indexed list |
pattern Empty :: forall k (f :: k -> Type) (xs :: [k]). () => (~) [k] xs ([] k) => TypedList k f xs | Zero-length type list; synonym to |
pattern TypeList :: forall k (xs :: [k]). () => RepresentableList k xs => TypeList k xs | Pattern matching against this causes |
pattern Cons :: forall k (f :: k -> Type) (xs :: [k]). () => forall (y :: k) (ys :: [k]). (~) [k] xs ((:) k y ys) => f y -> TypedList k f ys -> TypedList k f xs | Constructing a type-indexed list in the canonical way |
pattern Snoc :: forall k (f :: k -> Type) (xs :: [k]). () => forall (sy :: [k]) (y :: k). (~) [k] xs ((+:) k sy y) => TypedList k f sy -> f y -> TypedList k f xs | Constructing a type-indexed list from the other end |
pattern Reverse :: forall k (f :: k -> Type) (xs :: [k]). () => forall (sx :: [k]). ((~) [k] xs (Reverse k sx), (~) [k] sx (Reverse k xs)) => TypedList k f sx -> TypedList k f xs | Reverse a typed list |
Dim3 k (TypedList k (Dim k)) ((:) k d1 ((:) k d2 ((:) k d3 ds))) Source # | |
Dim2 k (TypedList k (Dim k)) ((:) k d1 ((:) k d2 ds)) Source # | |
Dim1 k (TypedList k (Dim k)) ((:) k d ds) Source # | |
(RepresentableList * xs, All * Bounded xs) => Bounded (Tuple xs) | |
(RepresentableList * xs, All * Bounded xs) => Bounded (Tuple xs) | |
All * Eq xs => Eq (Tuple xs) | |
All * Eq xs => Eq (Tuple xs) | |
(All * Eq xs, All * Ord xs) => Ord (Tuple xs) | Ord instance of the Tuple implements inverse lexicorgaphic ordering. That is, the last element in the tuple is the most significant one. Note, this will never work on infinite-dimensional tuples! |
(All * Eq xs, All * Ord xs) => Ord (Tuple xs) | Ord instance of the Tuple implements inverse lexicorgaphic ordering. That is, the last element in the tuple is the most significant one. Note, this will never work on infinite-dimensional tuples! |
(RepresentableList * xs, All * Read xs) => Read (Tuple xs) | |
(RepresentableList * xs, All * Read xs) => Read (Tuple xs) | |
All * Show xs => Show (Tuple xs) | |
All * Show xs => Show (Tuple xs) | |
All * Semigroup xs => Semigroup (Tuple xs) | |
All * Semigroup xs => Semigroup (Tuple xs) | |
(Semigroup (Tuple xs), RepresentableList Type xs, All * Monoid xs) => Monoid (Tuple xs) | |
(Semigroup (Tuple xs), RepresentableList Type xs, All * Monoid xs) => Monoid (Tuple xs) | |
(RepresentableList * xs, All * PrimBytes xs) => PrimBytes (Tuple xs) Source # | |
(RepresentableList * xs, All * PrimBytes xs) => PrimBytes (Tuple xs) Source # | |
Dimensions k ds => Bounded (Idxs k ds) | |
Dimensions k ds => Enum (Idxs k ds) | |
Eq (Idxs k xs) | |
KnownDim k n => Num (Idxs k ((:) k n ([] k))) | With this instance we can slightly reduce indexing expressions, e.g. x ! (1 :* 2 :* 4) == x ! (1 :* 2 :* 4 :* U) |
Ord (Idxs k xs) | Compare indices by their importance in lexicorgaphic order
from the last dimension to the first dimension
(the last dimension is the most significant one) Literally, compare a b = compare (reverse $ listIdxs a) (reverse $ listIdxs b) This is the same sort == sortOn fromEnum |
Show (Idxs k xs) | |
RepresentableList * xs => PrimBytes (Idxs * xs) Source # | |