Safe Haskell | None |
---|---|
Language | Haskell2010 |
The core easytensor
types.
Synopsis
- data SomeDataFrame (t :: l) = (Dimensions ns, KnownBackends t ns) => SomeDataFrame (DataFrame t ns)
- data DataFrame' (xs :: [k]) (t :: l)
- data family DataFrame (t :: l) (xs :: [k])
- pattern Z :: forall (xs :: [Type]) (ns :: [Nat]). () => xs ~ '[] => DataFrame xs ns
- pattern (:*:) :: forall (xs :: [Type]) (ns :: [Nat]). () => forall (y :: Type) (ys :: [Type]). xs ~ (y ': ys) => DataFrame y ns -> DataFrame ys ns -> DataFrame xs ns
- pattern S :: forall (t :: Type). t -> DataFrame t ('[] :: [Nat])
- pattern DF2 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (2 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t (2 ': ds)
- pattern DF3 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (3 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t (3 ': ds)
- pattern DF4 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (4 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t (4 ': ds)
- pattern DF5 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (5 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t (5 ': ds)
- pattern DF6 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (6 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t (6 ': ds)
- pattern DF7 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (7 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t (7 ': ds)
- pattern DF8 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (8 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t (8 ': ds)
- pattern DF9 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (9 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t (9 ': ds)
- type family PackDF (t :: Type) (ds :: [Nat]) (d :: Nat) (r :: Type) :: Type where ...
- packDF :: forall (t :: Type) (d :: Nat) (ds :: [Nat]). (PrimBytes t, Dimensions (d ': ds)) => PackDF t ds d (DataFrame t (d ': ds))
- unpackDF :: forall (t :: Type) (d :: Nat) (ds :: [Nat]) (rep :: RuntimeRep) (r :: TYPE rep). (PrimBytes t, Dimensions (d ': ds)) => PackDF t ds d (Dict (Dimensions ds, KnownBackend t ds) -> r) -> DataFrame t (d ': ds) -> r
- appendDF :: forall (n :: Nat) (m :: Nat) (ds :: [Nat]) (t :: Type). (PrimBytes t, Dimensions ds, KnownDim n, KnownDim m) => DataFrame t (n :+ ds) -> DataFrame t (m :+ ds) -> DataFrame t ((n + m) :+ ds)
- consDF :: forall (n :: Nat) (ds :: [Nat]) (t :: Type). (PrimBytes t, Dimensions ds, KnownDim n) => DataFrame t ds -> DataFrame t (n :+ ds) -> DataFrame t ((n + 1) :+ ds)
- snocDF :: forall (n :: Nat) (ds :: [Nat]) (t :: Type). (PrimBytes t, Dimensions ds, KnownDim n) => DataFrame t (n :+ ds) -> DataFrame t ds -> DataFrame t ((n + 1) :+ ds)
- fromFlatList :: forall (t :: Type) (ds :: [Nat]). PrimArray t (DataFrame t ds) => Dims ds -> t -> [t] -> DataFrame t ds
- fromListWithDefault :: forall (t :: Type) (d :: Nat) (ds :: [Nat]). (PrimBytes t, Dimensions (d ': ds)) => DataFrame t ds -> [DataFrame t ds] -> DataFrame t (d ': ds)
- fromList :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions ds) => [DataFrame t ds] -> DataFrame t (XN 0 ': AsXDims ds)
- constrainDF :: forall (ds :: [XNat]) (ys :: [XNat]) (l :: Type) (ts :: l). (BoundedDims ds, All KnownXNatType ds) => DataFrame ts ys -> Maybe (DataFrame ts ds)
- type KnownBackend t (ds :: [Nat]) = KnownBackend t ds (BackendFamily t ds)
- type DFBackend t (ds :: [Nat]) = Backend I t ds (BackendFamily t ds)
- type family KnownBackends (ts :: l) (ns :: [Nat]) :: Constraint where ...
- class InferKnownBackend (t :: k) ds where
- inferKnownBackend :: Dict (KnownBackends t ds)
- inferPrimElem :: forall (t :: Type) (d :: Nat) (ds :: [Nat]). KnownBackend t (d ': ds) => DataFrame t (d ': ds) -> Dict (PrimBytes t)
- data Dim (x :: k) :: forall k. k -> Type where
- pattern D :: forall (n :: Nat). () => KnownDim n => Dim n
- pattern D1 :: forall (n :: Nat). () => n ~ 1 => Dim n
- pattern D25 :: forall (n :: Nat). () => n ~ 25 => Dim n
- pattern D24 :: forall (n :: Nat). () => n ~ 24 => Dim n
- pattern D23 :: forall (n :: Nat). () => n ~ 23 => Dim n
- pattern D22 :: forall (n :: Nat). () => n ~ 22 => Dim n
- pattern D21 :: forall (n :: Nat). () => n ~ 21 => Dim n
- pattern D20 :: forall (n :: Nat). () => n ~ 20 => Dim n
- pattern D19 :: forall (n :: Nat). () => n ~ 19 => Dim n
- pattern D18 :: forall (n :: Nat). () => n ~ 18 => Dim n
- pattern D17 :: forall (n :: Nat). () => n ~ 17 => Dim n
- pattern D16 :: forall (n :: Nat). () => n ~ 16 => Dim n
- pattern D15 :: forall (n :: Nat). () => n ~ 15 => Dim n
- pattern D14 :: forall (n :: Nat). () => n ~ 14 => Dim n
- pattern D13 :: forall (n :: Nat). () => n ~ 13 => Dim n
- pattern D12 :: forall (n :: Nat). () => n ~ 12 => Dim n
- pattern D11 :: forall (n :: Nat). () => n ~ 11 => Dim n
- pattern D10 :: forall (n :: Nat). () => n ~ 10 => Dim n
- pattern D9 :: forall (n :: Nat). () => n ~ 9 => Dim n
- pattern D8 :: forall (n :: Nat). () => n ~ 8 => Dim n
- pattern D7 :: forall (n :: Nat). () => n ~ 7 => Dim n
- pattern D6 :: forall (n :: Nat). () => n ~ 6 => Dim n
- pattern D5 :: forall (n :: Nat). () => n ~ 5 => Dim n
- pattern D4 :: forall (n :: Nat). () => n ~ 4 => Dim n
- pattern D3 :: forall (n :: Nat). () => n ~ 3 => Dim n
- pattern D2 :: forall (n :: Nat). () => n ~ 2 => Dim n
- pattern D0 :: forall (n :: Nat). () => n ~ 0 => Dim n
- pattern Dx :: forall (xn :: XNat). KnownXNatType xn => forall (n :: Nat) (m :: Nat). (KnownDim n, m <= n, xn ~ XN m) => Dim n -> Dim xn
- pattern Dn :: forall (xn :: XNat). KnownXNatType xn => forall (n :: Nat). (KnownDim n, xn ~ N n) => Dim n -> Dim xn
- data Idx (n :: k) :: forall k. k -> Type
- data XNat
- type N (n :: Nat) = N n
- type XN (n :: Nat) = XN n
- type Dims (xs :: [k]) = TypedList (Dim :: k -> Type) xs
- type Idxs (xs :: [k]) = TypedList (Idx :: k -> Type) xs
- data TypedList (f :: k -> Type) (xs :: [k]) :: forall k. (k -> Type) -> [k] -> Type where
- pattern Empty :: forall k (f :: k -> Type) (xs :: [k]). () => xs ~ ([] :: [k]) => TypedList f xs
- pattern Snoc :: forall k (f :: k -> Type) (xs :: [k]). () => forall (sy :: [k]) (y :: k). xs ~ (sy +: y) => TypedList f sy -> f y -> TypedList f xs
- pattern Reverse :: forall k (f :: k -> Type) (xs :: [k]). () => forall (sx :: [k]). (xs ~ Reverse sx, sx ~ Reverse xs) => TypedList f sx -> TypedList f xs
- pattern Cons :: forall k (f :: k -> Type) (xs :: [k]). () => forall (y :: k) (ys :: [k]). xs ~ (y ': ys) => f y -> TypedList f ys -> TypedList f xs
- pattern TypeList :: forall k (xs :: [k]). () => RepresentableList xs => TypeList xs
- pattern (:*) :: forall k (f :: k -> Type) (xs :: [k]). () => forall (y :: k) (ys :: [k]). xs ~ (y ': ys) => f y -> TypedList f ys -> TypedList f xs
- pattern U :: forall k (f :: k -> Type) (xs :: [k]). () => xs ~ ([] :: [k]) => TypedList f xs
- pattern AsXDims :: forall (ns :: [Nat]). () => (KnownXNatTypes (AsXDims ns), RepresentableList (AsXDims ns)) => Dims (AsXDims ns) -> Dims ns
- pattern Dims :: forall (ds :: [Nat]). () => Dimensions ds => Dims ds
- pattern XDims :: forall (xns :: [XNat]). KnownXNatTypes xns => forall (ns :: [Nat]). (FixedDims xns ns, Dimensions ns) => Dims ns -> Dims xns
- pattern KnownDims :: forall (ds :: [Nat]). () => (All KnownDim ds, All (BoundedDim :: Nat -> Constraint) ds, RepresentableList ds, Dimensions ds) => Dims ds
- class PrimTagged a => PrimBytes a
- bSizeOf :: (PrimBytes a, Num b) => a -> b
- bAlignOf :: (PrimBytes a, Num b) => a -> b
- bFieldOffsetOf :: forall (name :: Symbol) (a :: Type) (b :: Type). (PrimBytes a, Elem name (PrimFields a), KnownSymbol name, Num b) => a -> b
- class PrimBytes t => PrimArray t a | a -> t
- ixOff :: PrimArray t a => Int -> a -> t
Data types
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, KnownBackends t ns) => SomeDataFrame (DataFrame t ns) |
Instances
data DataFrame' (xs :: [k]) (t :: l) Source #
DataFrame with its type arguments swapped.
Instances
(Data (DataFrame t xs), Typeable t, Typeable xs, Typeable k, Typeable l) => Data (DataFrame' xs t) Source # | |
Defined in Numeric.DataFrame.Type gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DataFrame' xs t -> c (DataFrame' xs t) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (DataFrame' xs t) # toConstr :: DataFrame' xs t -> Constr # dataTypeOf :: DataFrame' xs t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (DataFrame' xs t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (DataFrame' xs t)) # gmapT :: (forall b. Data b => b -> b) -> DataFrame' xs t -> DataFrame' xs t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DataFrame' xs t -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DataFrame' xs t -> r # gmapQ :: (forall d. Data d => d -> u) -> DataFrame' xs t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> DataFrame' xs t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> DataFrame' xs t -> m (DataFrame' xs t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DataFrame' xs t -> m (DataFrame' xs t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DataFrame' xs t -> m (DataFrame' xs t) # |
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
pattern Z :: forall (xs :: [Type]) (ns :: [Nat]). () => xs ~ '[] => DataFrame xs ns Source #
Empty MultiFrame
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 S :: forall (t :: Type). t -> DataFrame t ('[] :: [Nat]) Source #
A scalar DataFrame is just a newtype wrapper on a value.
pattern DF2 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (2 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t (2 ': ds) Source #
pattern DF3 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (3 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t (3 ': ds) Source #
pattern DF4 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (4 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t (4 ': ds) Source #
pattern DF5 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (5 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t (5 ': ds) Source #
pattern DF6 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (6 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t (6 ': ds) Source #
pattern DF7 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (7 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t (7 ': ds) Source #
pattern DF8 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (8 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t (8 ': ds) Source #
pattern DF9 :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions (9 ': ds)) => (Dimensions ds, KnownBackend t ds) => DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t ds -> DataFrame t (9 ': ds) Source #
Flexible assembling and disassembling
packDF :: forall (t :: Type) (d :: Nat) (ds :: [Nat]). (PrimBytes t, Dimensions (d ': ds)) => PackDF t ds d (DataFrame t (d ': ds)) Source #
Takes d
arguments of type DataFrame t ds
and produce a DataFrame t (d ': ds)
.
NB: always use TypeApplications
extension with this function to apply all
type arguments!
Otherwise, a very dumb type family PackDF
will not infer the types for you.
The following example creates a Matrix Double 12 3
filled with twelve
3D vectors (using fromInteger
of Vector Double 3
):
>>>
packDF @Double @12 @'[3] 1 2 3 4 5 6 7 8 9 10 11 12
packDF
and unpackDF
together serve as a generic constructor for a DataFrame
of an arbitrary (statically known) size.
unpackDF :: forall (t :: Type) (d :: Nat) (ds :: [Nat]) (rep :: RuntimeRep) (r :: TYPE rep). (PrimBytes t, Dimensions (d ': ds)) => PackDF t ds d (Dict (Dimensions ds, KnownBackend t ds) -> r) -> DataFrame t (d ': ds) -> r Source #
Takes a function (e.g. a constructor) with d+1
argument (df1, df2, .. dfd, Dict)
and a DataFrame t (d ': ds)
.
Feeds the dataframe elements into that function.
For example, you can pass a tuple to this function, and get all dataframe elements
(and some dictionaries -- useful evidence to work with element frames)
NB: always use TypeApplications
extension with this function to apply all
type arguments!
Otherwise, a very dumb type family PackDF
will not infer the types for you.
The following example unpacks a 3D vector
(created using fromInteger
of Vector Double 3
)
into a 4-tuple with three scalars and one Dict:
>>>
unpackDF @Double @3 @'[] (,,,) 2
packDF
and unpackDF
together serve as a generic constructor for a DataFrame
of an arbitrary (statically known) size.
appendDF :: forall (n :: Nat) (m :: Nat) (ds :: [Nat]) (t :: Type). (PrimBytes t, Dimensions ds, KnownDim n, KnownDim m) => DataFrame t (n :+ ds) -> DataFrame t (m :+ ds) -> DataFrame t ((n + m) :+ ds) Source #
consDF :: forall (n :: Nat) (ds :: [Nat]) (t :: Type). (PrimBytes t, Dimensions ds, KnownDim n) => DataFrame t ds -> DataFrame t (n :+ ds) -> DataFrame t ((n + 1) :+ ds) Source #
snocDF :: forall (n :: Nat) (ds :: [Nat]) (t :: Type). (PrimBytes t, Dimensions ds, KnownDim n) => DataFrame t (n :+ ds) -> DataFrame t ds -> DataFrame t ((n + 1) :+ ds) Source #
fromFlatList :: forall (t :: Type) (ds :: [Nat]). PrimArray t (DataFrame t ds) => Dims ds -> t -> [t] -> DataFrame t ds Source #
Construct a DataFrame from a flat list.
The values are filled according to the DataFrame layout: row-by-row and further from the last dimension (least significant) to the first dimension (most significant).
If the argument list is shorter than totalDim
, then the rest of the frame
is padded with a default value (second argument).
If the argument list is longer than totalDim
, then unused values are dropped.
If you want, you can pass an infinite list as an argument, i.e. the following
is a valid use:
>>>
fromFlatList (dims :: Dims '[2,5]) 0 [6,8..]
fromListWithDefault :: forall (t :: Type) (d :: Nat) (ds :: [Nat]). (PrimBytes t, Dimensions (d ': ds)) => DataFrame t ds -> [DataFrame t ds] -> DataFrame t (d ': ds) Source #
Construct a DataFrame from a list of smaller DataFrames.
If the argument list is shorter than d
, then the rest of the frame
is padded with a default value (first argument).
If the argument list is longer than d
, then unused values are dropped.
If you want, you can pass an infinite list as an argument.
fromList :: forall (t :: Type) (ds :: [Nat]). (PrimBytes t, Dimensions ds) => [DataFrame t ds] -> DataFrame t (XN 0 ': AsXDims ds) Source #
Construct a dynamic DataFrame from a list of smaller DataFrames.
Pattern-match against the resulting XFrame
to find out its dimensionality.
You must not provide an infinite list as an argument.
constrainDF :: forall (ds :: [XNat]) (ys :: [XNat]) (l :: Type) (ts :: l). (BoundedDims ds, All KnownXNatType ds) => DataFrame ts ys -> Maybe (DataFrame ts ds) Source #
Try to convert between XNat
-indexed DataFrames.
This is useful for imposing restrictions on unknown DataFrames, e.g. increasing the minimum number of elements.
Infer type class instances
type KnownBackend t (ds :: [Nat]) = KnownBackend t ds (BackendFamily t ds) Source #
type family KnownBackends (ts :: l) (ns :: [Nat]) :: Constraint where ... Source #
I use this kind-polymorphic constraint to generalize XFrame
and SomeDataFrame
over SingleFrame
and MultiFrame
.
KnownBackends (t :: Type) ns = KnownBackend t ns | |
KnownBackends ('[] :: [Type]) _ = () | |
KnownBackends (t ': ts :: [Type]) ns = (KnownBackend t ns, KnownBackends ts ns) |
class InferKnownBackend (t :: k) ds where Source #
Allow inferring KnownBackends
if you know the dimensions and the element types.
inferKnownBackend :: Dict (KnownBackends t ds) Source #
Instances
(PrimBytes t, Dimensions ds) => InferKnownBackend (t :: Type) ds Source # | |
Defined in Numeric.DataFrame.Type inferKnownBackend :: Dict (KnownBackends t ds) Source # | |
(RepresentableList ts, All PrimBytes ts, Dimensions ds) => InferKnownBackend (ts :: [Type]) ds Source # | |
Defined in Numeric.DataFrame.Type inferKnownBackend :: Dict (KnownBackends ts ds) Source # |
inferPrimElem :: forall (t :: Type) (d :: Nat) (ds :: [Nat]). KnownBackend t (d ': ds) => DataFrame t (d ': ds) -> Dict (PrimBytes t) Source #
Evidence that the elements of the DataFrame are PrimBytes.
Re-exports
data Dim (x :: k) :: forall k. k -> Type 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 D :: forall (n :: Nat). () => KnownDim n => Dim n | Match against this pattern to bring |
pattern D1 :: forall (n :: Nat). () => n ~ 1 => Dim n | Match |
pattern D25 :: forall (n :: Nat). () => n ~ 25 => Dim n | Match |
pattern D24 :: forall (n :: Nat). () => n ~ 24 => Dim n | Match |
pattern D23 :: forall (n :: Nat). () => n ~ 23 => Dim n | Match |
pattern D22 :: forall (n :: Nat). () => n ~ 22 => Dim n | Match |
pattern D21 :: forall (n :: Nat). () => n ~ 21 => Dim n | Match |
pattern D20 :: forall (n :: Nat). () => n ~ 20 => Dim n | Match |
pattern D19 :: forall (n :: Nat). () => n ~ 19 => Dim n | Match |
pattern D18 :: forall (n :: Nat). () => n ~ 18 => Dim n | Match |
pattern D17 :: forall (n :: Nat). () => n ~ 17 => Dim n | Match |
pattern D16 :: forall (n :: Nat). () => n ~ 16 => Dim n | Match |
pattern D15 :: forall (n :: Nat). () => n ~ 15 => Dim n | Match |
pattern D14 :: forall (n :: Nat). () => n ~ 14 => Dim n | Match |
pattern D13 :: forall (n :: Nat). () => n ~ 13 => Dim n | Match |
pattern D12 :: forall (n :: Nat). () => n ~ 12 => Dim n | Match |
pattern D11 :: forall (n :: Nat). () => n ~ 11 => Dim n | Match |
pattern D10 :: forall (n :: Nat). () => n ~ 10 => Dim n | Match |
pattern D9 :: forall (n :: Nat). () => n ~ 9 => Dim n | Match |
pattern D8 :: forall (n :: Nat). () => n ~ 8 => Dim n | Match |
pattern D7 :: forall (n :: Nat). () => n ~ 7 => Dim n | Match |
pattern D6 :: forall (n :: Nat). () => n ~ 6 => Dim n | Match |
pattern D5 :: forall (n :: Nat). () => n ~ 5 => Dim n | Match |
pattern D4 :: forall (n :: Nat). () => n ~ 4 => Dim n | Match |
pattern D3 :: forall (n :: Nat). () => n ~ 3 => Dim n | Match |
pattern D2 :: forall (n :: Nat). () => n ~ 2 => Dim n | Match |
pattern D0 :: forall (n :: Nat). () => n ~ 0 => Dim n | Match |
pattern Dx :: forall (xn :: XNat). KnownXNatType xn => forall (n :: Nat) (m :: Nat). (KnownDim n, m <= n, xn ~ XN m) => Dim n -> Dim xn |
|
pattern Dn :: forall (xn :: XNat). KnownXNatType xn => forall (n :: Nat). (KnownDim n, xn ~ N n) => Dim n -> Dim xn | Statically known |
Instances
Eq (Dims ds) | |
Eq (Dims ds) | |
Eq (Dim n) | |
Eq (Dim x) | |
Typeable d => Data (Dim d) | |
Defined in Numeric.Dimensions.Dim gfoldl :: (forall d0 b. Data d0 => c (d0 -> b) -> d0 -> c b) -> (forall g. g -> c g) -> Dim d -> c (Dim d) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Dim d) # dataTypeOf :: Dim d -> DataType # dataCast1 :: Typeable t => (forall d0. Data d0 => c (t d0)) -> Maybe (c (Dim d)) # dataCast2 :: Typeable t => (forall d0 e. (Data d0, Data e) => c (t d0 e)) -> Maybe (c (Dim d)) # gmapT :: (forall b. Data b => b -> b) -> Dim d -> Dim d # gmapQl :: (r -> r' -> r) -> r -> (forall d0. Data d0 => d0 -> r') -> Dim d -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d0. Data d0 => d0 -> r') -> Dim d -> r # gmapQ :: (forall d0. Data d0 => d0 -> u) -> Dim d -> [u] # gmapQi :: Int -> (forall d0. Data d0 => d0 -> u) -> Dim d -> u # gmapM :: Monad m => (forall d0. Data d0 => d0 -> m d0) -> Dim d -> m (Dim d) # gmapMp :: MonadPlus m => (forall d0. Data d0 => d0 -> m d0) -> Dim d -> m (Dim d) # gmapMo :: MonadPlus m => (forall d0. Data d0 => d0 -> m d0) -> Dim d -> m (Dim d) # | |
Ord (Dims ds) | |
Ord (Dims ds) | |
Ord (Dim n) | |
Ord (Dim x) | |
BoundedDims xs => Read (Dims xs) | |
BoundedDim x => Read (Dim x) | |
Show (Dims xs) | |
Show (Dim x) | |
KnownDim d => Generic (Dim d) | |
type Rep (Dim d) | |
data Idx (n :: k) :: forall k. k -> Type #
This type is used to index a single dimension;
the range of indices is from 0
to n-1
.
Instances
BoundedDim n => Bounded (Idx n) | |
BoundedDims ds => Bounded (Idxs ds) | |
BoundedDim n => Enum (Idx n) | |
Defined in Numeric.Dimensions.Idx | |
Dimensions ds => Enum (Idxs ds) | |
Eq (Idx n) | |
Eq (Idxs xs) | |
BoundedDim n => Integral (Idx n) | |
(Typeable n, Typeable k) => Data (Idx n) | |
Defined in Numeric.Dimensions.Idx gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Idx n -> c (Idx n) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Idx n) # dataTypeOf :: Idx n -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Idx n)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Idx n)) # gmapT :: (forall b. Data b => b -> b) -> Idx n -> Idx n # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Idx n -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Idx n -> r # gmapQ :: (forall d. Data d => d -> u) -> Idx n -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Idx n -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Idx n -> m (Idx n) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Idx n -> m (Idx n) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Idx n -> m (Idx n) # | |
BoundedDim n => Num (Idx n) | |
BoundedDim n => Num (Idxs (n ': ([] :: [k]))) | With this instance we can slightly reduce indexing expressions, e.g. x ! (1 :* 2 :* 4) == x ! (1 :* 2 :* 4 :* U) |
Defined in Numeric.Dimensions.Idx (+) :: Idxs (n ': []) -> Idxs (n ': []) -> Idxs (n ': []) # (-) :: Idxs (n ': []) -> Idxs (n ': []) -> Idxs (n ': []) # (*) :: Idxs (n ': []) -> Idxs (n ': []) -> Idxs (n ': []) # negate :: Idxs (n ': []) -> Idxs (n ': []) # abs :: Idxs (n ': []) -> Idxs (n ': []) # signum :: Idxs (n ': []) -> Idxs (n ': []) # fromInteger :: Integer -> Idxs (n ': []) # | |
Ord (Idx n) | |
Ord (Idxs xs) | Compare indices by their importance in lexicorgaphic order from the first dimension to the last dimension (the first dimension is the most significant one). Literally, compare a b = compare (listIdxs a) (listIdxs b) This is the same sort == sortOn fromEnum |
BoundedDim x => Read (Idx x) | |
BoundedDims xs => Read (Idxs xs) | |
BoundedDim n => Real (Idx n) | |
Defined in Numeric.Dimensions.Idx toRational :: Idx n -> Rational # | |
Show (Idx x) | |
Show (Idxs xs) | |
Generic (Idx n) | |
Storable (Idx n) | |
PrimBytes (Idx x) Source # | |
Defined in Numeric.PrimBytes type PrimFields (Idx x) :: [Symbol] Source # getBytes :: Idx x -> ByteArray# Source # getBytesPinned :: Idx x -> ByteArray# Source # fromBytes :: Int# -> ByteArray# -> Idx x Source # readBytes :: MutableByteArray# s -> Int# -> State# s -> (#State# s, Idx x#) Source # writeBytes :: MutableByteArray# s -> Int# -> Idx x -> State# s -> State# s Source # readAddr :: Addr# -> State# s -> (#State# s, Idx x#) Source # writeAddr :: Idx x -> Addr# -> State# s -> State# s Source # byteSize :: Idx x -> Int# Source # byteAlign :: Idx x -> Int# Source # byteOffset :: Idx x -> Int# Source # byteFieldOffset :: (Elem name (PrimFields (Idx x)), KnownSymbol name) => Proxy# name -> Idx x -> Int# Source # indexArray :: ByteArray# -> Int# -> Idx x Source # readArray :: MutableByteArray# s -> Int# -> State# s -> (#State# s, Idx x#) Source # writeArray :: MutableByteArray# s -> Int# -> Idx x -> State# s -> State# s Source # | |
RepresentableList xs => PrimBytes (Idxs xs) Source # | |
Defined in Numeric.PrimBytes type PrimFields (Idxs xs) :: [Symbol] Source # getBytes :: Idxs xs -> ByteArray# Source # getBytesPinned :: Idxs xs -> ByteArray# Source # fromBytes :: Int# -> ByteArray# -> Idxs xs Source # readBytes :: MutableByteArray# s -> Int# -> State# s -> (#State# s, Idxs xs#) Source # writeBytes :: MutableByteArray# s -> Int# -> Idxs xs -> State# s -> State# s Source # readAddr :: Addr# -> State# s -> (#State# s, Idxs xs#) Source # writeAddr :: Idxs xs -> Addr# -> State# s -> State# s Source # byteSize :: Idxs xs -> Int# Source # byteAlign :: Idxs xs -> Int# Source # byteOffset :: Idxs xs -> Int# Source # byteFieldOffset :: (Elem name (PrimFields (Idxs xs)), KnownSymbol name) => Proxy# name -> Idxs xs -> Int# Source # indexArray :: ByteArray# -> Int# -> Idxs xs Source # readArray :: MutableByteArray# s -> Int# -> State# s -> (#State# s, Idxs xs#) Source # writeArray :: MutableByteArray# s -> Int# -> Idxs xs -> State# s -> State# s Source # | |
type Rep (Idx n) | |
Defined in Numeric.Dimensions.Idx | |
type PrimFields (Idx x) Source # | |
Defined in Numeric.PrimBytes | |
type PrimFields (Idxs xs) Source # | |
Defined in Numeric.PrimBytes |
Either known or unknown at compile-time natural number
Instances
KnownDimKind XNat | |
Defined in Numeric.Dimensions.Dim | |
MatrixTranspose (t :: Type) (xn :: XNat) (xm :: XNat) Source # | |
KnownDim n => BoundedDim (N n :: XNat) | |
KnownDim m => BoundedDim (XN m :: XNat) | |
BoundedDims ([] :: [XNat]) | |
Defined in Numeric.Dimensions.Dim dimsBound :: Dims (DimsBound []) # constrainDims :: Dims ys -> Maybe (Dims []) # inferAllBoundedDims :: Dict (All BoundedDim [], RepresentableList []) # | |
(BoundedDim n, BoundedDims ns) => BoundedDims (n ': ns :: [XNat]) | |
Defined in Numeric.Dimensions.Dim dimsBound :: Dims (DimsBound (n ': ns)) # constrainDims :: Dims ys -> Maybe (Dims (n ': ns)) # inferAllBoundedDims :: Dict (All BoundedDim (n ': ns), RepresentableList (n ': ns)) # | |
Eq (Dims ds) | |
Eq (Dim x) | |
Ord (Dims ds) | |
Ord (Dim x) | |
All Eq ts => Eq (DataFrame ts ds) Source # | |
Eq t => Eq (DataFrame t ds) Source # | |
(All Read ts, All PrimBytes ts, RepresentableList ts, BoundedDims ds, All KnownXNatType ds) => Read (DataFrame ts ds) Source # | |
(Read t, PrimBytes t, BoundedDims ds, All KnownXNatType ds) => Read (DataFrame t ds) Source # | |
(All Show ts, All PrimBytes ts) => Show (DataFrame ts xns) Source # | |
(Show t, PrimBytes t) => Show (DataFrame t xns) Source # | |
data STDataFrame s t (xs :: [XNat]) Source # | Data frame with some dimensions missing at compile time. Pattern-match against its constructor to get a Nat-indexed mutable data frame. |
Defined in Numeric.DataFrame.ST data STDataFrame s t (xs :: [XNat]) where
| |
data IODataFrame t (xs :: [XNat]) Source # | Data frame with some dimensions missing at compile time. Pattern-match against its constructor to get a Nat-indexed mutable data frame. |
Defined in Numeric.DataFrame.IO data IODataFrame t (xs :: [XNat]) where
| |
data DataFrame (ts :: l) (xns :: [XNat]) Source # | Data frame with some dimensions missing at compile time. Pattern-match against its constructor to get a Nat-indexed data frame. |
Defined in Numeric.DataFrame.Type data DataFrame (ts :: l) (xns :: [XNat]) where
| |
type DimBound (N n :: XNat) | |
Defined in Numeric.Dimensions.Dim | |
type DimBound (XN m :: XNat) | |
Defined in Numeric.Dimensions.Dim | |
type DimsBound ([] :: [XNat]) | |
Defined in Numeric.Dimensions.Dim | |
type DimsBound (n ': ns :: [XNat]) | |
Defined in Numeric.Dimensions.Dim |
type Idxs (xs :: [k]) = TypedList (Idx :: k -> Type) 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.
data TypedList (f :: k -> Type) (xs :: [k]) :: forall k. (k -> Type) -> [k] -> Type where #
Type-indexed list
pattern Empty :: forall k (f :: k -> Type) (xs :: [k]). () => xs ~ ([] :: [k]) => TypedList f xs | Zero-length type list; synonym to |
pattern Snoc :: forall k (f :: k -> Type) (xs :: [k]). () => forall (sy :: [k]) (y :: k). xs ~ (sy +: y) => TypedList f sy -> f y -> TypedList f xs | Constructing a type-indexed list from the other end |
pattern Reverse :: forall k (f :: k -> Type) (xs :: [k]). () => forall (sx :: [k]). (xs ~ Reverse sx, sx ~ Reverse xs) => TypedList f sx -> TypedList f xs | Reverse a typed list |
pattern Cons :: forall k (f :: k -> Type) (xs :: [k]). () => forall (y :: k) (ys :: [k]). xs ~ (y ': ys) => f y -> TypedList f ys -> TypedList f xs | Constructing a type-indexed list in the canonical way |
pattern TypeList :: forall k (xs :: [k]). () => RepresentableList xs => TypeList xs | Pattern matching against this causes |
pattern (:*) :: forall k (f :: k -> Type) (xs :: [k]). () => forall (y :: k) (ys :: [k]). xs ~ (y ': ys) => f y -> TypedList f ys -> TypedList f xs infixr 5 | Constructing a type-indexed list |
pattern U :: forall k (f :: k -> Type) (xs :: [k]). () => xs ~ ([] :: [k]) => TypedList f xs | Zero-length type list |
pattern AsXDims :: forall (ns :: [Nat]). () => (KnownXNatTypes (AsXDims ns), RepresentableList (AsXDims ns)) => Dims (AsXDims ns) -> Dims ns | An easy way to convert Nat-indexed dims into XNat-indexed dims. |
pattern Dims :: forall (ds :: [Nat]). () => Dimensions ds => Dims ds |
|
pattern XDims :: forall (xns :: [XNat]). KnownXNatTypes xns => forall (ns :: [Nat]). (FixedDims xns ns, Dimensions ns) => Dims ns -> Dims xns | Pattern-matching against this constructor reveals Nat-kinded list of dims,
pretending the dimensionality is known at compile time within the scope
of the pattern match.
This is the main recommended way to get In order to use this pattern, one must know |
pattern KnownDims :: forall (ds :: [Nat]). () => (All KnownDim ds, All (BoundedDim :: Nat -> Constraint) ds, RepresentableList ds, Dimensions ds) => Dims ds |
|
Instances
class PrimTagged a => PrimBytes a Source #
Defines how to read and write your data to and from Haskell unboxed byte arrays and plain pointers.
Similarly to Storable
, this class provides functions to get
the size and alignment of a data via phantom arguments.
Thus, the size and alignment of the data must not depend on the data content
(they depend only on the type of the data).
In particular, this means that dynamically sized structures like Haskell lists
or maps are not allowed.
This module provides default implementations for all methods of this class via
Generic
. Hence, to make your data an instance of PrimBytes
,
it is sufficient to write the instance head:
data MyData a b = ... deriving Generic instance (PrimBytes a, PrimBytes b) => PrimBytes (MyData a b)
.. or use the DeriveAnyClass
extension to make it even shorter:
data MyData a b = ... deriving (Generic, PrimBytes)
The derived instance tries to pack the data as dense as possible, but sometimes
it is better to write the instance by hand.
If a derived type has more than one constructor, the derived instance puts
a Word32
tag at the beginning of the byte representation.
All fields of a constructor are packed in a C-like fashion next to each other,
while respecting their alignments.
Instances
bFieldOffsetOf :: forall (name :: Symbol) (a :: Type) (b :: Type). (PrimBytes a, Elem name (PrimFields a), KnownSymbol name, Num b) => a -> b Source #
A wrapper on byteFieldOffset
.
class PrimBytes t => PrimArray t a | a -> t Source #