easytensor-1.0.0.0: Pure, type-indexed haskell vector, matrix, and tensor library.

Safe HaskellNone
LanguageHaskell2010

Numeric.DataFrame.Type

Contents

Synopsis

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

Instances

Dim3 XNat (DataFrame l1 XNat l2) ((:) XNat d1 ((:) XNat d2 ((:) XNat d3 ds))) Source # 

Methods

dim3 :: (XNat ': d1) ((XNat ': d2) ((XNat ': d3) ds)) ds -> Dim (DataFrame l1 XNat l2) (Head (DataFrame l1 XNat l2) (Tail (DataFrame l1 XNat l2) (Tail (DataFrame l1 XNat l2) ds))) Source #

Dim2 XNat (DataFrame l1 XNat l2) ((:) XNat d1 ((:) XNat d2 ds)) Source # 

Methods

dim2 :: (XNat ': d1) ((XNat ': d2) ds) ds -> Dim (DataFrame l1 XNat l2) (Head (DataFrame l1 XNat l2) (Tail (DataFrame l1 XNat l2) ds)) Source #

Dim1 XNat (DataFrame l1 XNat l2) ((:) XNat d ds) Source # 

Methods

dim1 :: (XNat ': d) ds ds -> Dim (DataFrame l1 XNat l2) (Head (DataFrame l1 XNat l2) 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 l XNat where
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

Constructors

(Dimensions ns, ArraySingletons t ns) => SomeDataFrame (DataFrame t ns) 

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 #

Equations

AllTypes f (t :: Type) = f t 
AllTypes f (ts :: [Type]) = All f ts 

type family ImplAllows (f :: Type -> Constraint) (ts :: l) (ds :: [Nat]) :: Constraint where ... Source #

Equations

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 #

Equations

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 #

Equations

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 #

Minimal complete definition

inferASing, inferEq, inferShow, inferPrim, inferPrimElem

Methods

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.

Instances

DataFrameInference Type t Source # 
RepresentableList Type ts => DataFrameInference [Type] ts Source # 

Methods

inferASing :: (AllTypes ts PrimBytes t, Dimensions Nat ds) => DataFrame ts Nat t ds -> Evidence (ArraySingletons ts t ds) Source #

inferEq :: (AllTypes ts Eq t, ArraySingletons ts t ds) => DataFrame ts Nat t ds -> Evidence (Eq (DataFrame ts Nat t ds)) Source #

inferShow :: (AllTypes ts Show t, ArraySingletons ts t ds, Dimensions Nat ds) => DataFrame ts Nat t ds -> Evidence (Show (DataFrame ts Nat t ds)) Source #

inferPrim :: (AllTypes ts PrimBytes t, ArraySingletons ts t ds, Dimensions Nat ds) => DataFrame ts Nat t ds -> Evidence (PrimFrames ts t ds) Source #

inferPrimElem :: (ArraySingletons ts t ds, ([Nat] ~ ds) ((Nat ': Head Nat ds) (Tail Nat ds))) => DataFrame ts Nat t ds -> Evidence (AllTypes ts PrimBytes t) 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 #

inferFloating :: forall t ds. (Floating t, ArraySingleton t ds) => DataFrame t ds -> Evidence (Floating (DataFrame t ds)) Source #

inferOrd' :: forall t ds. (Ord t, ArraySingleton t ds) => Evidence (Ord (DataFrame t ds)) Source #

inferNum' :: forall t ds. (Num t, ArraySingletons t ds) => Evidence (Num (DataFrame t ds)) Source #

inferPrimElem' :: forall t ds. (DataFrameInference t, ArraySingletons t ds, ds ~ (Head ds ': Tail ds)) => Evidence (AllTypes PrimBytes t) Source #

Misc

ixOff :: PrimArray t a => Int -> a -> t Source #

Index array by an integer offset (starting from 0).

unsafeFromFlatList :: PrimArray t a => Int -> [t] -> a Source #

Construct an array from a flat list and length

class Dim1 (t :: [k] -> Type) (ds :: [k]) where Source #

Minimal complete definition

dim1

Methods

dim1 :: t ds -> Dim (Head ds) Source #

Instances

Dimensions k ((:) k d ds) => Dim1 k t ((:) k d ds) Source # 

Methods

dim1 :: (k ': d) ds ds -> Dim t (Head t ds) Source #

Dim1 k (TypedList k (Dim k)) ((:) k d ds) Source # 

Methods

dim1 :: (k ': d) ds ds -> Dim (TypedList k (Dim k)) (Head (TypedList k (Dim k)) ds) Source #

Dim1 XNat (DataFrame l1 XNat l2) ((:) XNat d ds) Source # 

Methods

dim1 :: (XNat ': d) ds ds -> Dim (DataFrame l1 XNat l2) (Head (DataFrame l1 XNat l2) ds) Source #

class Dim2 (t :: [k] -> Type) (ds :: [k]) where Source #

Minimal complete definition

dim2

Methods

dim2 :: t ds -> Dim (Head (Tail ds)) Source #

Instances

Dimensions k ((:) k d1 ((:) k d2 ds)) => Dim2 k t ((:) k d1 ((:) k d2 ds)) Source # 

Methods

dim2 :: (k ': d1) ((k ': d2) ds) ds -> Dim t (Head t (Tail t ds)) Source #

Dim2 k (TypedList k (Dim k)) ((:) k d1 ((:) k d2 ds)) Source # 

Methods

dim2 :: (k ': d1) ((k ': d2) ds) ds -> Dim (TypedList k (Dim k)) (Head (TypedList k (Dim k)) (Tail (TypedList k (Dim k)) ds)) Source #

Dim2 XNat (DataFrame l1 XNat l2) ((:) XNat d1 ((:) XNat d2 ds)) Source # 

Methods

dim2 :: (XNat ': d1) ((XNat ': d2) ds) ds -> Dim (DataFrame l1 XNat l2) (Head (DataFrame l1 XNat l2) (Tail (DataFrame l1 XNat l2) ds)) Source #

class Dim3 (t :: [k] -> Type) (ds :: [k]) where Source #

Minimal complete definition

dim3

Methods

dim3 :: t ds -> Dim (Head (Tail (Tail ds))) Source #

Instances

Dimensions k ((:) k d1 ((:) k d2 ((:) k d3 ds))) => Dim3 k t ((:) k d1 ((:) k d2 ((:) k d3 ds))) Source # 

Methods

dim3 :: (k ': d1) ((k ': d2) ((k ': d3) ds)) ds -> Dim t (Head t (Tail t (Tail t ds))) Source #

Dim3 k (TypedList k (Dim k)) ((:) k d1 ((:) k d2 ((:) k d3 ds))) Source # 

Methods

dim3 :: (k ': d1) ((k ': d2) ((k ': d3) ds)) ds -> Dim (TypedList k (Dim k)) (Head (TypedList k (Dim k)) (Tail (TypedList k (Dim k)) (Tail (TypedList k (Dim k)) ds))) Source #

Dim3 XNat (DataFrame l1 XNat l2) ((:) XNat d1 ((:) XNat d2 ((:) XNat d3 ds))) Source # 

Methods

dim3 :: (XNat ': d1) ((XNat ': d2) ((XNat ': d3) ds)) ds -> Dim (DataFrame l1 XNat l2) (Head (DataFrame l1 XNat l2) (Tail (DataFrame l1 XNat l2) (Tail (DataFrame l1 XNat l2) ds))) Source #

dimSize1 :: Dim1 t ds => t ds -> Word Source #

Number of elements along the 1st dimension.

dimSize2 :: Dim2 t ds => t ds -> Word Source #

Number of elements along the 2nd dimension.

dimSize3 :: Dim3 t ds => t ds -> Word Source #

Number of elements along the 3rd dimension.

bSizeOf :: PrimBytes a => a -> Int Source #

A wrapper on byteSize

bAlignOf :: PrimBytes a => a -> Int Source #

A wrapper on byteAlign

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 XNats to represent them.

Bundled Patterns

pattern Dim :: forall k (n :: k). () => KnownDim k n => Dim k n

Independently of the kind of type-level number, construct an instance of KnownDim from it.

Match against this pattern to bring KnownDim instance into scope when you don't know the kind of the Dim parameter.

pattern D :: forall (n :: Nat). () => KnownDim Nat n => Dim Nat n

Same as Dim pattern, but constrained to Nat kind.

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 XNat

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

XNat that is unknown at compile time. Same as SomeNat, but for a dimension: Hide dimension size inside, but allow specifying its minimum possible value.

Instances

Dim3 k (TypedList k (Dim k)) ((:) k d1 ((:) k d2 ((:) k d3 ds))) Source # 

Methods

dim3 :: (k ': d1) ((k ': d2) ((k ': d3) ds)) ds -> Dim (TypedList k (Dim k)) (Head (TypedList k (Dim k)) (Tail (TypedList k (Dim k)) (Tail (TypedList k (Dim k)) ds))) Source #

Dim2 k (TypedList k (Dim k)) ((:) k d1 ((:) k d2 ds)) Source # 

Methods

dim2 :: (k ': d1) ((k ': d2) ds) ds -> Dim (TypedList k (Dim k)) (Head (TypedList k (Dim k)) (Tail (TypedList k (Dim k)) ds)) Source #

Dim1 k (TypedList k (Dim k)) ((:) k d ds) Source # 

Methods

dim1 :: (k ': d) ds ds -> Dim (TypedList k (Dim k)) (Head (TypedList k (Dim k)) ds) Source #

Eq (Dim Nat n) 

Methods

(==) :: Dim Nat n -> Dim Nat n -> Bool #

(/=) :: Dim Nat n -> Dim Nat n -> Bool #

Eq (Dim XNat x) 

Methods

(==) :: Dim XNat x -> Dim XNat x -> Bool #

(/=) :: Dim XNat x -> Dim XNat x -> Bool #

Ord (Dim Nat n) 

Methods

compare :: Dim Nat n -> Dim Nat n -> Ordering #

(<) :: Dim Nat n -> Dim Nat n -> Bool #

(<=) :: Dim Nat n -> Dim Nat n -> Bool #

(>) :: Dim Nat n -> Dim Nat n -> Bool #

(>=) :: Dim Nat n -> Dim Nat n -> Bool #

max :: Dim Nat n -> Dim Nat n -> Dim Nat n #

min :: Dim Nat n -> Dim Nat n -> Dim Nat n #

Ord (Dim XNat x) 

Methods

compare :: Dim XNat x -> Dim XNat x -> Ordering #

(<) :: Dim XNat x -> Dim XNat x -> Bool #

(<=) :: Dim XNat x -> Dim XNat x -> Bool #

(>) :: Dim XNat x -> Dim XNat x -> Bool #

(>=) :: Dim XNat x -> Dim XNat x -> Bool #

max :: Dim XNat x -> Dim XNat x -> Dim XNat x #

min :: Dim XNat x -> Dim XNat x -> Dim XNat x #

KnownDim Nat m => Read (Dim XNat (XN m)) 
Show (Dim k x) 

Methods

showsPrec :: Int -> Dim k x -> ShowS #

show :: Dim k x -> String #

showList :: [Dim k x] -> ShowS #

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`.

Constructors

Idx 

Fields

Instances

Generic1 k (Idx k) 

Associated Types

type Rep1 (Idx k) (f :: Idx k -> *) :: k -> * #

Methods

from1 :: f a -> Rep1 (Idx k) f a #

to1 :: Rep1 (Idx k) f a -> f a #

KnownDim k n => Bounded (Idx k n) 

Methods

minBound :: Idx k n #

maxBound :: Idx k n #

Dimensions k ds => Bounded (Idxs k ds) 

Methods

minBound :: Idxs k ds #

maxBound :: Idxs k ds #

KnownDim k n => Enum (Idx k n) 

Methods

succ :: Idx k n -> Idx k n #

pred :: Idx k n -> Idx k n #

toEnum :: Int -> Idx k n #

fromEnum :: Idx k n -> Int #

enumFrom :: Idx k n -> [Idx k n] #

enumFromThen :: Idx k n -> Idx k n -> [Idx k n] #

enumFromTo :: Idx k n -> Idx k n -> [Idx k n] #

enumFromThenTo :: Idx k n -> Idx k n -> Idx k n -> [Idx k n] #

Dimensions k ds => Enum (Idxs k ds) 

Methods

succ :: Idxs k ds -> Idxs k ds #

pred :: Idxs k ds -> Idxs k ds #

toEnum :: Int -> Idxs k ds #

fromEnum :: Idxs k ds -> Int #

enumFrom :: Idxs k ds -> [Idxs k ds] #

enumFromThen :: Idxs k ds -> Idxs k ds -> [Idxs k ds] #

enumFromTo :: Idxs k ds -> Idxs k ds -> [Idxs k ds] #

enumFromThenTo :: Idxs k ds -> Idxs k ds -> Idxs k ds -> [Idxs k ds] #

Eq (Idx k n) 

Methods

(==) :: Idx k n -> Idx k n -> Bool #

(/=) :: Idx k n -> Idx k n -> Bool #

Eq (Idxs k xs) 

Methods

(==) :: Idxs k xs -> Idxs k xs -> Bool #

(/=) :: Idxs k xs -> Idxs k xs -> Bool #

KnownDim k n => Integral (Idx k n) 

Methods

quot :: Idx k n -> Idx k n -> Idx k n #

rem :: Idx k n -> Idx k n -> Idx k n #

div :: Idx k n -> Idx k n -> Idx k n #

mod :: Idx k n -> Idx k n -> Idx k n #

quotRem :: Idx k n -> Idx k n -> (Idx k n, Idx k n) #

divMod :: Idx k n -> Idx k n -> (Idx k n, Idx k n) #

toInteger :: Idx k n -> Integer #

(Typeable * k, Typeable k n) => Data (Idx k n) 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Idx k n -> c (Idx k n) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Idx k n) #

toConstr :: Idx k n -> Constr #

dataTypeOf :: Idx k n -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Idx k n)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Idx k n)) #

gmapT :: (forall b. Data b => b -> b) -> Idx k n -> Idx k n #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Idx k n -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Idx k n -> r #

gmapQ :: (forall d. Data d => d -> u) -> Idx k n -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Idx k n -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Idx k n -> m (Idx k n) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Idx k n -> m (Idx k n) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Idx k n -> m (Idx k n) #

KnownDim k n => Num (Idx k n) 

Methods

(+) :: Idx k n -> Idx k n -> Idx k n #

(-) :: Idx k n -> Idx k n -> Idx k n #

(*) :: Idx k n -> Idx k n -> Idx k n #

negate :: Idx k n -> Idx k n #

abs :: Idx k n -> Idx k n #

signum :: Idx k n -> Idx k n #

fromInteger :: Integer -> 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)

Methods

(+) :: Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) #

(-) :: Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) #

(*) :: Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) #

negate :: Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) #

abs :: Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) #

signum :: Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) #

fromInteger :: Integer -> Idxs k ((k ': n) [k]) #

Ord (Idx k n) 

Methods

compare :: Idx k n -> Idx k n -> Ordering #

(<) :: Idx k n -> Idx k n -> Bool #

(<=) :: Idx k n -> Idx k n -> Bool #

(>) :: Idx k n -> Idx k n -> Bool #

(>=) :: Idx k n -> Idx k n -> Bool #

max :: Idx k n -> Idx k n -> Idx k n #

min :: Idx k n -> Idx k n -> 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) O(Length xs).

Literally,

compare a b = compare (reverse $ listIdxs a) (reverse $ listIdxs b)

This is the same compare rule, as for Dims. Another reason to reverse the list of indices is to have a consistent behavior when calculating index offsets:

sort == sortOn fromEnum

Methods

compare :: Idxs k xs -> Idxs k xs -> Ordering #

(<) :: Idxs k xs -> Idxs k xs -> Bool #

(<=) :: Idxs k xs -> Idxs k xs -> Bool #

(>) :: Idxs k xs -> Idxs k xs -> Bool #

(>=) :: Idxs k xs -> Idxs k xs -> Bool #

max :: Idxs k xs -> Idxs k xs -> Idxs k xs #

min :: Idxs k xs -> Idxs k xs -> Idxs k xs #

Read (Idx k n) 

Methods

readsPrec :: Int -> ReadS (Idx k n) #

readList :: ReadS [Idx k n] #

readPrec :: ReadPrec (Idx k n) #

readListPrec :: ReadPrec [Idx k n] #

KnownDim k n => Real (Idx k n) 

Methods

toRational :: Idx k n -> Rational #

Show (Idx k n) 

Methods

showsPrec :: Int -> Idx k n -> ShowS #

show :: Idx k n -> String #

showList :: [Idx k n] -> ShowS #

Show (Idxs k xs) 

Methods

showsPrec :: Int -> Idxs k xs -> ShowS #

show :: Idxs k xs -> String #

showList :: [Idxs k xs] -> ShowS #

Generic (Idx k n) 

Associated Types

type Rep (Idx k n) :: * -> * #

Methods

from :: Idx k n -> Rep (Idx k n) x #

to :: Rep (Idx k n) x -> Idx k n #

Storable (Idx k n) 

Methods

sizeOf :: Idx k n -> Int #

alignment :: Idx k n -> Int #

peekElemOff :: Ptr (Idx k n) -> Int -> IO (Idx k n) #

pokeElemOff :: Ptr (Idx k n) -> Int -> Idx k n -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Idx k n) #

pokeByteOff :: Ptr b -> Int -> Idx k n -> IO () #

peek :: Ptr (Idx k n) -> IO (Idx k n) #

poke :: Ptr (Idx k n) -> Idx k n -> IO () #

PrimBytes (Idx * x) Source # 
RepresentableList * xs => PrimBytes (Idxs * xs) Source # 
type Rep1 k (Idx k) 
type Rep1 k (Idx k) = D1 k (MetaData "Idx" "Numeric.Dimensions.Idxs" "dimensions-1.0.0.0-JqapYVXbO0lFbcgM5G0LVG" True) (C1 k (MetaCons "Idx" PrefixI True) (S1 k (MetaSel (Just Symbol "unIdx") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 k Word)))
type Rep (Idx k n) 
type Rep (Idx k n) = D1 * (MetaData "Idx" "Numeric.Dimensions.Idxs" "dimensions-1.0.0.0-JqapYVXbO0lFbcgM5G0LVG" True) (C1 * (MetaCons "Idx" PrefixI True) (S1 * (MetaSel (Just Symbol "unIdx") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Word)))

data XNat :: * #

Either known or unknown at compile-time natural number

Constructors

XN Nat 
N Nat 

Instances

KnownDimKind XNat 

Methods

dimKind :: DimKind XNat #

DataFrameToList XNat t xns xz Source # 

Methods

toList :: DataFrame Type t xns ((t +: xz) z) -> [DataFrame Type t xns xz] Source #

KnownDim Nat n => KnownDim XNat (N n) 

Methods

dim :: Dim (N n) n #

Dim3 XNat (DataFrame l1 XNat l2) ((:) XNat d1 ((:) XNat d2 ((:) XNat d3 ds))) Source # 

Methods

dim3 :: (XNat ': d1) ((XNat ': d2) ((XNat ': d3) ds)) ds -> Dim (DataFrame l1 XNat l2) (Head (DataFrame l1 XNat l2) (Tail (DataFrame l1 XNat l2) (Tail (DataFrame l1 XNat l2) ds))) Source #

Dim2 XNat (DataFrame l1 XNat l2) ((:) XNat d1 ((:) XNat d2 ds)) Source # 

Methods

dim2 :: (XNat ': d1) ((XNat ': d2) ds) ds -> Dim (DataFrame l1 XNat l2) (Head (DataFrame l1 XNat l2) (Tail (DataFrame l1 XNat l2) ds)) Source #

Dim1 XNat (DataFrame l1 XNat l2) ((:) XNat d ds) Source # 

Methods

dim1 :: (XNat ': d) ds ds -> Dim (DataFrame l1 XNat l2) (Head (DataFrame l1 XNat l2) ds) Source #

Eq (Dim XNat x) 

Methods

(==) :: Dim XNat x -> Dim XNat x -> Bool #

(/=) :: Dim XNat x -> Dim XNat x -> Bool #

Ord (Dim XNat x) 

Methods

compare :: Dim XNat x -> Dim XNat x -> Ordering #

(<) :: Dim XNat x -> Dim XNat x -> Bool #

(<=) :: Dim XNat x -> Dim XNat x -> Bool #

(>) :: Dim XNat x -> Dim XNat x -> Bool #

(>=) :: Dim XNat x -> Dim XNat x -> Bool #

max :: Dim XNat x -> Dim XNat x -> Dim XNat x #

min :: Dim XNat x -> Dim XNat x -> 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.

data DataFrame l XNat where

type Dims k (xs :: [k]) = TypedList k (Dim k) xs #

Type-level dimensionality O(1).

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

Bundled Patterns

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 U.

pattern TypeList :: forall k (xs :: [k]). () => RepresentableList k xs => TypeList k xs

Pattern matching against this causes RepresentableList instance come into scope. Also it allows constructing a term-level list out of a constraint.

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

Instances

Dim3 k (TypedList k (Dim k)) ((:) k d1 ((:) k d2 ((:) k d3 ds))) Source # 

Methods

dim3 :: (k ': d1) ((k ': d2) ((k ': d3) ds)) ds -> Dim (TypedList k (Dim k)) (Head (TypedList k (Dim k)) (Tail (TypedList k (Dim k)) (Tail (TypedList k (Dim k)) ds))) Source #

Dim2 k (TypedList k (Dim k)) ((:) k d1 ((:) k d2 ds)) Source # 

Methods

dim2 :: (k ': d1) ((k ': d2) ds) ds -> Dim (TypedList k (Dim k)) (Head (TypedList k (Dim k)) (Tail (TypedList k (Dim k)) ds)) Source #

Dim1 k (TypedList k (Dim k)) ((:) k d ds) Source # 

Methods

dim1 :: (k ': d) ds ds -> Dim (TypedList k (Dim k)) (Head (TypedList k (Dim k)) ds) Source #

(RepresentableList * xs, All * Bounded xs) => Bounded (Tuple xs) 

Methods

minBound :: Tuple xs #

maxBound :: Tuple xs #

(RepresentableList * xs, All * Bounded xs) => Bounded (Tuple xs) 

Methods

minBound :: Tuple xs #

maxBound :: Tuple xs #

All * Eq xs => Eq (Tuple xs) 

Methods

(==) :: Tuple xs -> Tuple xs -> Bool #

(/=) :: Tuple xs -> Tuple xs -> Bool #

All * Eq xs => Eq (Tuple xs) 

Methods

(==) :: Tuple xs -> Tuple xs -> Bool #

(/=) :: Tuple xs -> Tuple xs -> Bool #

(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!

Methods

compare :: Tuple xs -> Tuple xs -> Ordering #

(<) :: Tuple xs -> Tuple xs -> Bool #

(<=) :: Tuple xs -> Tuple xs -> Bool #

(>) :: Tuple xs -> Tuple xs -> Bool #

(>=) :: Tuple xs -> Tuple xs -> Bool #

max :: Tuple xs -> Tuple xs -> Tuple xs #

min :: Tuple xs -> Tuple xs -> 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!

Methods

compare :: Tuple xs -> Tuple xs -> Ordering #

(<) :: Tuple xs -> Tuple xs -> Bool #

(<=) :: Tuple xs -> Tuple xs -> Bool #

(>) :: Tuple xs -> Tuple xs -> Bool #

(>=) :: Tuple xs -> Tuple xs -> Bool #

max :: Tuple xs -> Tuple xs -> Tuple xs #

min :: Tuple xs -> Tuple xs -> Tuple xs #

(RepresentableList * xs, All * Read xs) => Read (Tuple xs) 
(RepresentableList * xs, All * Read xs) => Read (Tuple xs) 
All * Show xs => Show (Tuple xs) 

Methods

showsPrec :: Int -> Tuple xs -> ShowS #

show :: Tuple xs -> String #

showList :: [Tuple xs] -> ShowS #

All * Show xs => Show (Tuple xs) 

Methods

showsPrec :: Int -> Tuple xs -> ShowS #

show :: Tuple xs -> String #

showList :: [Tuple xs] -> ShowS #

All * Semigroup xs => Semigroup (Tuple xs) 

Methods

(<>) :: Tuple xs -> Tuple xs -> Tuple xs #

sconcat :: NonEmpty (Tuple xs) -> Tuple xs #

stimes :: Integral b => b -> Tuple xs -> Tuple xs #

All * Semigroup xs => Semigroup (Tuple xs) 

Methods

(<>) :: Tuple xs -> Tuple xs -> Tuple xs #

sconcat :: NonEmpty (Tuple xs) -> Tuple xs #

stimes :: Integral b => b -> Tuple xs -> Tuple xs #

(Semigroup (Tuple xs), RepresentableList Type xs, All * Monoid xs) => Monoid (Tuple xs) 

Methods

mempty :: Tuple xs #

mappend :: Tuple xs -> Tuple xs -> Tuple xs #

mconcat :: [Tuple xs] -> Tuple xs #

(Semigroup (Tuple xs), RepresentableList Type xs, All * Monoid xs) => Monoid (Tuple xs) 

Methods

mempty :: Tuple xs #

mappend :: Tuple xs -> Tuple xs -> Tuple xs #

mconcat :: [Tuple xs] -> 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) 

Methods

minBound :: Idxs k ds #

maxBound :: Idxs k ds #

Dimensions k ds => Enum (Idxs k ds) 

Methods

succ :: Idxs k ds -> Idxs k ds #

pred :: Idxs k ds -> Idxs k ds #

toEnum :: Int -> Idxs k ds #

fromEnum :: Idxs k ds -> Int #

enumFrom :: Idxs k ds -> [Idxs k ds] #

enumFromThen :: Idxs k ds -> Idxs k ds -> [Idxs k ds] #

enumFromTo :: Idxs k ds -> Idxs k ds -> [Idxs k ds] #

enumFromThenTo :: Idxs k ds -> Idxs k ds -> Idxs k ds -> [Idxs k ds] #

Eq (Idxs k xs) 

Methods

(==) :: Idxs k xs -> Idxs k xs -> Bool #

(/=) :: Idxs k xs -> Idxs k xs -> Bool #

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)

Methods

(+) :: Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) #

(-) :: Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) #

(*) :: Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) #

negate :: Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) #

abs :: Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) #

signum :: Idxs k ((k ': n) [k]) -> Idxs k ((k ': n) [k]) #

fromInteger :: Integer -> Idxs k ((k ': n) [k]) #

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) O(Length xs).

Literally,

compare a b = compare (reverse $ listIdxs a) (reverse $ listIdxs b)

This is the same compare rule, as for Dims. Another reason to reverse the list of indices is to have a consistent behavior when calculating index offsets:

sort == sortOn fromEnum

Methods

compare :: Idxs k xs -> Idxs k xs -> Ordering #

(<) :: Idxs k xs -> Idxs k xs -> Bool #

(<=) :: Idxs k xs -> Idxs k xs -> Bool #

(>) :: Idxs k xs -> Idxs k xs -> Bool #

(>=) :: Idxs k xs -> Idxs k xs -> Bool #

max :: Idxs k xs -> Idxs k xs -> Idxs k xs #

min :: Idxs k xs -> Idxs k xs -> Idxs k xs #

Show (Idxs k xs) 

Methods

showsPrec :: Int -> Idxs k xs -> ShowS #

show :: Idxs k xs -> String #

showList :: [Idxs k xs] -> ShowS #

RepresentableList * xs => PrimBytes (Idxs * xs) Source # 

Orphan instances

(PrimArray t (Array t ds), PrimBytes t) => PrimArray t (DataFrame * Nat t ds) Source # 

Methods

broadcast :: t -> DataFrame * Nat t ds Source #

ix# :: Int# -> DataFrame * Nat t ds -> t Source #

gen# :: Int# -> (s -> (#LiftedRep, LiftedRep, s, t#)) -> s -> (#LiftedRep, LiftedRep, s, DataFrame * Nat t ds#) Source #

upd# :: Int# -> Int# -> t -> DataFrame * Nat t ds -> DataFrame * Nat t ds Source #

elemOffset :: DataFrame * Nat t ds -> Int# Source #

elemSize0 :: DataFrame * Nat t ds -> Int# Source #

fromElems :: Int# -> Int# -> ByteArray# -> DataFrame * Nat t ds Source #

Bounded (Array t ds) => Bounded (DataFrame Type Nat t ds) Source # 
Enum (Array t ds) => Enum (DataFrame Type Nat t ds) Source # 
ImplAllows [Type] Eq ts ds => Eq (DataFrame [Type] Nat ts ds) Source # 

Methods

(==) :: DataFrame [Type] Nat ts ds -> DataFrame [Type] Nat ts ds -> Bool #

(/=) :: DataFrame [Type] Nat ts ds -> DataFrame [Type] Nat ts ds -> Bool #

Eq (Array t ds) => Eq (DataFrame Type Nat t ds) Source # 

Methods

(==) :: DataFrame Type Nat t ds -> DataFrame Type Nat t ds -> Bool #

(/=) :: DataFrame Type Nat t ds -> DataFrame Type Nat t ds -> Bool #

(AllTypes l Eq t, DataFrameInference l t) => Eq (DataFrame l XNat t ds) Source # 

Methods

(==) :: DataFrame l XNat t ds -> DataFrame l XNat t ds -> Bool #

(/=) :: DataFrame l XNat t ds -> DataFrame l XNat t ds -> Bool #

Floating (Array t ds) => Floating (DataFrame Type Nat t ds) Source # 
Fractional (Array t ds) => Fractional (DataFrame Type Nat t ds) Source # 
Integral (Array t ds) => Integral (DataFrame Type Nat t ds) Source # 
Num (Array t ds) => Num (DataFrame Type Nat t ds) Source # 
Ord (Array t ds) => Ord (DataFrame Type Nat t ds) Source # 

Methods

compare :: DataFrame Type Nat t ds -> DataFrame Type Nat t ds -> Ordering #

(<) :: DataFrame Type Nat t ds -> DataFrame Type Nat t ds -> Bool #

(<=) :: DataFrame Type Nat t ds -> DataFrame Type Nat t ds -> Bool #

(>) :: DataFrame Type Nat t ds -> DataFrame Type Nat t ds -> Bool #

(>=) :: DataFrame Type Nat t ds -> DataFrame Type Nat t ds -> Bool #

max :: DataFrame Type Nat t ds -> DataFrame Type Nat t ds -> DataFrame Type Nat t ds #

min :: DataFrame Type Nat t ds -> DataFrame Type Nat t ds -> DataFrame Type Nat t ds #

(Read (Array t ds), Dimensions Nat ds) => Read (DataFrame Type Nat t ds) Source # 
Real (Array t ds) => Real (DataFrame Type Nat t ds) Source # 
RealFloat (Array t ds) => RealFloat (DataFrame Type Nat t ds) Source # 
RealFrac (Array t ds) => RealFrac (DataFrame Type Nat t ds) Source # 

Methods

properFraction :: Integral b => DataFrame Type Nat t ds -> (b, DataFrame Type Nat t ds) #

truncate :: Integral b => DataFrame Type Nat t ds -> b #

round :: Integral b => DataFrame Type Nat t ds -> b #

ceiling :: Integral b => DataFrame Type Nat t ds -> b #

floor :: Integral b => DataFrame Type Nat t ds -> b #

(Dimensions Nat ds, ImplAllows [Type] Show ts ds) => Show (DataFrame [Type] Nat ts ds) Source # 

Methods

showsPrec :: Int -> DataFrame [Type] Nat ts ds -> ShowS #

show :: DataFrame [Type] Nat ts ds -> String #

showList :: [DataFrame [Type] Nat ts ds] -> ShowS #

(Show (Array t ds), Dimensions Nat ds) => Show (DataFrame Type Nat t ds) Source # 

Methods

showsPrec :: Int -> DataFrame Type Nat t ds -> ShowS #

show :: DataFrame Type Nat t ds -> String #

showList :: [DataFrame Type Nat t ds] -> ShowS #

(AllTypes l Show t, DataFrameInference l t) => Show (DataFrame l XNat t xns) Source # 

Methods

showsPrec :: Int -> DataFrame l XNat t xns -> ShowS #

show :: DataFrame l XNat t xns -> String #

showList :: [DataFrame l XNat t xns] -> ShowS #

PrimBytes (DataFrame l k t ds) => Storable (DataFrame l k t ds) Source # 

Methods

sizeOf :: DataFrame l k t ds -> Int #

alignment :: DataFrame l k t ds -> Int #

peekElemOff :: Ptr (DataFrame l k t ds) -> Int -> IO (DataFrame l k t ds) #

pokeElemOff :: Ptr (DataFrame l k t ds) -> Int -> DataFrame l k t ds -> IO () #

peekByteOff :: Ptr b -> Int -> IO (DataFrame l k t ds) #

pokeByteOff :: Ptr b -> Int -> DataFrame l k t ds -> IO () #

peek :: Ptr (DataFrame l k t ds) -> IO (DataFrame l k t ds) #

poke :: Ptr (DataFrame l k t ds) -> DataFrame l k t ds -> IO () #

PrimBytes (Array t ds) => PrimBytes (DataFrame Type Nat t ds) Source #