dimensions-2.1.1.0: Safe type-level dimensionality for multidimensional data.
Copyright(c) Artem Chirkin
LicenseBSD3
Safe HaskellNone
LanguageHaskell2010

Numeric.Dimensions.Dim

Description

This module provides KnownDim class that is similar to KnownNat from TypeNats, but keeps Words instead of Naturals; Also it provides Dim data type serving as a singleton suitable for recovering an instance of the KnownDim class. A set of utility functions provide inference functionality, so that KnownDim can be preserved over some type-level operations.

Provides a data type Dims ds to keep dimension sizes for multiple-dimensional data. Higher indices go first, i.e. assumed enumeration is i = i1*n1*n2*...*n(k-1) + ... + i(k-2)*n1*n2 + i(k-1)*n1 + ik This corresponds to row-first layout of matrices and multidimenional arrays.

Synopsis

Dim: a Nat-indexed dimension

Type level numbers that can be unknown.

data Nat #

(Kind) This is the kind of type-level natural numbers.

Instances

Instances details
KnownDimKind Nat Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Dimensions ns => BoundedDims (ns :: [Nat]) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dimsBound :: Dims (DimsBound ns) Source #

constrainDims :: forall k (ys :: [k]). Dims ys -> Maybe (Dims ns) Source #

KnownDim n => BoundedDim (n :: Nat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Associated Types

type DimBound n :: Nat Source #

Methods

dimBound :: Dim (DimBound n) Source #

constrainDim :: forall k (y :: k). Dim y -> Maybe (Dim n) Source #

KnownNat n => KnownDim (n :: Nat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim n Source #

KnownDim 0 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 0 Source #

KnownDim 1 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 1 Source #

KnownDim 2 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 2 Source #

KnownDim 3 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 3 Source #

KnownDim 4 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 4 Source #

KnownDim 5 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 5 Source #

KnownDim 6 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 6 Source #

KnownDim 7 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 7 Source #

KnownDim 8 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 8 Source #

KnownDim 9 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 9 Source #

KnownDim 10 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 10 Source #

KnownDim 11 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 11 Source #

KnownDim 12 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 12 Source #

KnownDim 13 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 13 Source #

KnownDim 14 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 14 Source #

KnownDim 15 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 15 Source #

KnownDim 16 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 16 Source #

KnownDim 17 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 17 Source #

KnownDim 18 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 18 Source #

KnownDim 19 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 19 Source #

KnownDim 20 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 20 Source #

KnownDim 21 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 21 Source #

KnownDim 22 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 22 Source #

KnownDim 23 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 23 Source #

KnownDim 24 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 24 Source #

KnownDim 25 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 25 Source #

KnownDimType (n :: Nat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dimType :: DimType n Source #

Class (KnownNat n) (KnownDim n) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

cls :: KnownDim n :- KnownNat n #

KnownDim n => Enum (Idx n) Source # 
Instance details

Defined in Numeric.Dimensions.Idx

Methods

succ :: Idx n -> Idx n #

pred :: Idx n -> Idx n #

toEnum :: Int -> Idx n #

fromEnum :: Idx n -> Int #

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

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

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

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

Eq (Dim n) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

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

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

Eq (Dims ds) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

(==) :: Dims ds -> Dims ds -> Bool #

(/=) :: Dims ds -> Dims ds -> Bool #

Typeable d => Data (Dim d) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

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) #

toConstr :: Dim d -> Constr #

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 :: forall r r'. (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) #

KnownDim n => Num (Idx n) Source # 
Instance details

Defined in Numeric.Dimensions.Idx

Methods

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

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

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

negate :: Idx n -> Idx n #

abs :: Idx n -> Idx n #

signum :: Idx n -> Idx n #

fromInteger :: Integer -> Idx n #

Ord (Dim n) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

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

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

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

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

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

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

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

Ord (Dims ds) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

compare :: Dims ds -> Dims ds -> Ordering #

(<) :: Dims ds -> Dims ds -> Bool #

(<=) :: Dims ds -> Dims ds -> Bool #

(>) :: Dims ds -> Dims ds -> Bool #

(>=) :: Dims ds -> Dims ds -> Bool #

max :: Dims ds -> Dims ds -> Dims ds #

min :: Dims ds -> Dims ds -> Dims ds #

KnownDim d => Generic (Dim d) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Associated Types

type Rep (Dim d) :: Type -> Type #

Methods

from :: Dim d -> Rep (Dim d) x #

to :: Rep (Dim d) x -> Dim d #

type DimBound (n :: Nat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

type DimBound (n :: Nat) = n
type Rep (Dim d) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

type Rep (Dim d) = D1 ('MetaData "Dim" "Numeric.Dim" "dimensions" 'False) (C1 ('MetaCons (AppendSymbol "D" (ShowNat d)) 'PrefixI 'False) (U1 :: Type -> Type))

data XNat Source #

Either known or unknown at compile-time natural number

Constructors

XN Nat 
N Nat 

Instances

Instances details
KnownDimKind XNat Source # 
Instance details

Defined in Numeric.Dimensions.Dim

BoundedDims ('[] :: [XNat]) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dimsBound :: Dims (DimsBound '[]) Source #

constrainDims :: forall k (ys :: [k]). Dims ys -> Maybe (Dims '[]) Source #

KnownDim n => BoundedDim (N n :: XNat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Associated Types

type DimBound (N n) :: Nat Source #

Methods

dimBound :: Dim (DimBound (N n)) Source #

constrainDim :: forall k (y :: k). Dim y -> Maybe (Dim (N n)) Source #

KnownDim m => BoundedDim (XN m :: XNat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Associated Types

type DimBound (XN m) :: Nat Source #

Methods

dimBound :: Dim (DimBound (XN m)) Source #

constrainDim :: forall k (y :: k). Dim y -> Maybe (Dim (XN m)) Source #

KnownDim n => KnownDim (N n :: XNat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim (N n) Source #

KnownDimType ('XN n :: XNat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dimType :: DimType ('XN n) Source #

KnownDimType ('N n :: XNat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dimType :: DimType ('N n) Source #

(BoundedDim n, BoundedDims ns) => BoundedDims (n ': ns :: [XNat]) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dimsBound :: Dims (DimsBound (n ': ns)) Source #

constrainDims :: forall k (ys :: [k]). Dims ys -> Maybe (Dims (n ': ns)) Source #

Eq (Dim x) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

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

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

Eq (Dims ds) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

(==) :: Dims ds -> Dims ds -> Bool #

(/=) :: Dims ds -> Dims ds -> Bool #

Ord (Dim x) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

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

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

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

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

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

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

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

Ord (Dims ds) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

compare :: Dims ds -> Dims ds -> Ordering #

(<) :: Dims ds -> Dims ds -> Bool #

(<=) :: Dims ds -> Dims ds -> Bool #

(>) :: Dims ds -> Dims ds -> Bool #

(>=) :: Dims ds -> Dims ds -> Bool #

max :: Dims ds -> Dims ds -> Dims ds #

min :: Dims ds -> Dims ds -> Dims ds #

type DimBound (N n :: XNat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

type DimBound (N n :: XNat) = n
type DimBound ('XN m :: XNat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

type DimBound ('XN m :: XNat) = m

type XN = 'XN Source #

Unknown natural number, known to be not smaller than the given Nat

type N = 'N Source #

Known natural number

data DimType (d :: k) where Source #

GADT to support KnownDimType type class. Find out if this type variable is a Nat or XNat, and whether XNat is of known or constrained type.

Constructors

DimTNat :: DimType (n :: Nat)

This is a plain Nat

DimTXNatN :: DimType (N n)

Given XNat is known

DimTXNatX :: DimType (XN m)

Given XNat is constrained unknown

class KnownDimType d where Source #

Figure out whether the type-level dimension is Nat, or `N Nat`, or `XN Nat`.

Methods

dimType :: DimType d Source #

Pattern-match against this to out the value (type) of the dim type variable.

Instances

Instances details
KnownDimType (n :: Nat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dimType :: DimType n Source #

KnownDimType ('XN n :: XNat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dimType :: DimType ('XN n) Source #

KnownDimType ('N n :: XNat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dimType :: DimType ('N n) Source #

Class (KnownDimKind k) (KnownDimType n) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

data DimKind (k :: Type) where Source #

GADT to support KnownDimKind type class. Match against its constructors to know if k is Nat or XNat

Constructors

DimKNat :: DimKind Nat

Working on Nat.

DimKXNat :: DimKind XNat

Working on XNat.

class KnownDimKind k where Source #

Figure out whether the type-level dimension is Nat or XNat.

Methods

dimKind :: DimKind k Source #

Pattern-match against this to out the kind of the dim type variable.

Instances

Instances details
KnownDimKind Nat Source # 
Instance details

Defined in Numeric.Dimensions.Dim

KnownDimKind XNat Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Class (KnownDimKind k) (KnownDimType n) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Term level dimension

data Dim (x :: k) where Source #

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 D :: forall d. KnownDimType d => (KindOf d ~ Nat, KnownDim d) => Dim d

Match against this pattern to bring KnownDim instance into scope.

pattern Dn :: forall d. KnownDimType d => forall (n :: Nat). d ~~ N n => Dim n -> Dim d

Statically known XNat

pattern Dx :: forall d. KnownDimType d => forall (m :: Nat) (n :: Nat). (d ~~ XN m, m <= n) => Dim n -> Dim d

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.

pattern D0 :: forall (n :: Nat). () => n ~ 0 => Dim n

Match Dim n against a concrete Nat

pattern D1 :: forall (n :: Nat). () => n ~ 1 => Dim n

Match Dim n against a concrete Nat

pattern D2 :: forall (n :: Nat). () => n ~ 2 => Dim n

Match Dim n against a concrete Nat

pattern D3 :: forall (n :: Nat). () => n ~ 3 => Dim n

Match Dim n against a concrete Nat

pattern D4 :: forall (n :: Nat). () => n ~ 4 => Dim n

Match Dim n against a concrete Nat

pattern D5 :: forall (n :: Nat). () => n ~ 5 => Dim n

Match Dim n against a concrete Nat

pattern D6 :: forall (n :: Nat). () => n ~ 6 => Dim n

Match Dim n against a concrete Nat

pattern D7 :: forall (n :: Nat). () => n ~ 7 => Dim n

Match Dim n against a concrete Nat

pattern D8 :: forall (n :: Nat). () => n ~ 8 => Dim n

Match Dim n against a concrete Nat

pattern D9 :: forall (n :: Nat). () => n ~ 9 => Dim n

Match Dim n against a concrete Nat

pattern D10 :: forall (n :: Nat). () => n ~ 10 => Dim n

Match Dim n against a concrete Nat

pattern D11 :: forall (n :: Nat). () => n ~ 11 => Dim n

Match Dim n against a concrete Nat

pattern D12 :: forall (n :: Nat). () => n ~ 12 => Dim n

Match Dim n against a concrete Nat

pattern D13 :: forall (n :: Nat). () => n ~ 13 => Dim n

Match Dim n against a concrete Nat

pattern D14 :: forall (n :: Nat). () => n ~ 14 => Dim n

Match Dim n against a concrete Nat

pattern D15 :: forall (n :: Nat). () => n ~ 15 => Dim n

Match Dim n against a concrete Nat

pattern D16 :: forall (n :: Nat). () => n ~ 16 => Dim n

Match Dim n against a concrete Nat

pattern D17 :: forall (n :: Nat). () => n ~ 17 => Dim n

Match Dim n against a concrete Nat

pattern D18 :: forall (n :: Nat). () => n ~ 18 => Dim n

Match Dim n against a concrete Nat

pattern D19 :: forall (n :: Nat). () => n ~ 19 => Dim n

Match Dim n against a concrete Nat

pattern D20 :: forall (n :: Nat). () => n ~ 20 => Dim n

Match Dim n against a concrete Nat

pattern D21 :: forall (n :: Nat). () => n ~ 21 => Dim n

Match Dim n against a concrete Nat

pattern D22 :: forall (n :: Nat). () => n ~ 22 => Dim n

Match Dim n against a concrete Nat

pattern D23 :: forall (n :: Nat). () => n ~ 23 => Dim n

Match Dim n against a concrete Nat

pattern D24 :: forall (n :: Nat). () => n ~ 24 => Dim n

Match Dim n against a concrete Nat

pattern D25 :: forall (n :: Nat). () => n ~ 25 => Dim n

Match Dim n against a concrete Nat

Instances

Instances details
Eq (Dim n) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

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

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

Eq (Dim x) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

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

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

Eq (Dims ds) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

(==) :: Dims ds -> Dims ds -> Bool #

(/=) :: Dims ds -> Dims ds -> Bool #

Eq (Dims ds) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

(==) :: Dims ds -> Dims ds -> Bool #

(/=) :: Dims ds -> Dims ds -> Bool #

Typeable d => Data (Dim d) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

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) #

toConstr :: Dim d -> Constr #

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 :: forall r r'. (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 (Dim n) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

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

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

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

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

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

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

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

Ord (Dim x) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

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

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

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

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

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

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

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

Ord (Dims ds) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

compare :: Dims ds -> Dims ds -> Ordering #

(<) :: Dims ds -> Dims ds -> Bool #

(<=) :: Dims ds -> Dims ds -> Bool #

(>) :: Dims ds -> Dims ds -> Bool #

(>=) :: Dims ds -> Dims ds -> Bool #

max :: Dims ds -> Dims ds -> Dims ds #

min :: Dims ds -> Dims ds -> Dims ds #

Ord (Dims ds) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

compare :: Dims ds -> Dims ds -> Ordering #

(<) :: Dims ds -> Dims ds -> Bool #

(<=) :: Dims ds -> Dims ds -> Bool #

(>) :: Dims ds -> Dims ds -> Bool #

(>=) :: Dims ds -> Dims ds -> Bool #

max :: Dims ds -> Dims ds -> Dims ds #

min :: Dims ds -> Dims ds -> Dims ds #

BoundedDim x => Read (Dim x) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

BoundedDims xs => Read (Dims xs) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Show (Dim x) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

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

show :: Dim x -> String #

showList :: [Dim x] -> ShowS #

Show (Dims xs) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

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

show :: Dims xs -> String #

showList :: [Dims xs] -> ShowS #

KnownDim d => Generic (Dim d) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Associated Types

type Rep (Dim d) :: Type -> Type #

Methods

from :: Dim d -> Rep (Dim d) x #

to :: Rep (Dim d) x -> Dim d #

type Rep (Dim d) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

type Rep (Dim d) = D1 ('MetaData "Dim" "Numeric.Dim" "dimensions" 'False) (C1 ('MetaCons (AppendSymbol "D" (ShowNat d)) 'PrefixI 'False) (U1 :: Type -> Type))

type SomeDim = Dim (XN 0) Source #

Same as SomeNat

class KnownDim n where Source #

This class provides the Dim associated with a type-level natural.

Note, kind of the KnownDim argument is usually Nat, because it is impossible to create a unique KnownDim (XN m) instance. Nevertheless, you can have KnownDim (N n), which is useful in some cases.

Methods

dim :: Dim n Source #

Get value of type-level dim at runtime.

Note, this function is supposed to be used with TypeApplications. For example, you can type:

>>> :set -XTypeApplications
>>> :set -XDataKinds
>>> :t dim @3
dim @3 :: Dim 3
>>> :set -XTypeOperators
>>> :t dim @(13 - 6)
dim @(13 - 6) :: Dim 7

Instances

Instances details
KnownNat n => KnownDim (n :: Nat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim n Source #

KnownDim 0 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 0 Source #

KnownDim 1 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 1 Source #

KnownDim 2 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 2 Source #

KnownDim 3 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 3 Source #

KnownDim 4 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 4 Source #

KnownDim 5 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 5 Source #

KnownDim 6 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 6 Source #

KnownDim 7 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 7 Source #

KnownDim 8 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 8 Source #

KnownDim 9 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 9 Source #

KnownDim 10 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 10 Source #

KnownDim 11 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 11 Source #

KnownDim 12 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 12 Source #

KnownDim 13 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 13 Source #

KnownDim 14 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 14 Source #

KnownDim 15 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 15 Source #

KnownDim 16 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 16 Source #

KnownDim 17 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 17 Source #

KnownDim 18 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 18 Source #

KnownDim 19 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 19 Source #

KnownDim 20 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 20 Source #

KnownDim 21 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 21 Source #

KnownDim 22 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 22 Source #

KnownDim 23 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 23 Source #

KnownDim 24 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 24 Source #

KnownDim 25 Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim 25 Source #

KnownDim n => KnownDim (N n :: XNat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dim :: Dim (N n) Source #

Class (KnownNat n) (KnownDim n) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

cls :: KnownDim n :- KnownNat n #

withKnownXDim :: forall (d :: XNat) (rep :: RuntimeRep) (r :: TYPE rep). KnownDim d => ((KnownDim (DimBound d), ExactDim d, KnownDimType d, FixedDim d (DimBound d)) => r) -> r Source #

If you have KnownDim d, then d can only be Nat or a known type of XNat (i.e. N n). This function assures the type checker that this is indeed the case.

class (KnownDimKind (KindOf d), KnownDimType d, KnownDim (DimBound d)) => BoundedDim d where Source #

Get a minimal or exact bound of a Dim.

To satisfy the BoundedDim means to be equal to N n or be not less than XN m.

Associated Types

type DimBound d :: Nat Source #

Minimal or exact bound of a Dim. Useful for indexing: it is safe to index something by an index less than DimBound n (for both Nat and Xnat indexed dims).

Methods

dimBound :: Dim (DimBound d) Source #

Get such a minimal Dim (DimBound n), that Dim n is guaranteed to be not less than dimBound if n ~ XN a, otherwise, the return Dim is the same as n.

constrainDim :: forall y. Dim y -> Maybe (Dim d) Source #

If the runtime value of Dim y satisfies dimBound x, then coerce to Dim x. Otherwise, return Nothing@.

To satisfy the dimBound means to be equal to N n or be not less than XN m.

Instances

Instances details
KnownDim n => BoundedDim (n :: Nat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Associated Types

type DimBound n :: Nat Source #

Methods

dimBound :: Dim (DimBound n) Source #

constrainDim :: forall k (y :: k). Dim y -> Maybe (Dim n) Source #

KnownDim n => BoundedDim (N n :: XNat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Associated Types

type DimBound (N n) :: Nat Source #

Methods

dimBound :: Dim (DimBound (N n)) Source #

constrainDim :: forall k (y :: k). Dim y -> Maybe (Dim (N n)) Source #

KnownDim m => BoundedDim (XN m :: XNat) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Associated Types

type DimBound (XN m) :: Nat Source #

Methods

dimBound :: Dim (DimBound (XN m)) Source #

constrainDim :: forall k (y :: k). Dim y -> Maybe (Dim (XN m)) Source #

minimalDim :: forall n. BoundedDim n => Dim n Source #

Returns the minimal Dim that satisfies the BoundedDim constraint (this is the exact dim for Nats and the minimal bound for XNats).

type family ExactDim (d :: k) :: Constraint where ... Source #

This is either Nat, or a known XNat (i.e. N n).

Equations

ExactDim (_ :: Nat) = () 
ExactDim (x :: XNat) = x ~ N (DimBound x) 

type family FixedDim (x :: XNat) (n :: Nat) :: Constraint where ... Source #

Constraints given by an XNat type on possible values of a Nat hidden inside.

Equations

FixedDim ('N a) b = a ~ b 
FixedDim ('XN m) b = m <= b 

dimVal :: forall x. Dim x -> Word Source #

Similar to natVal from TypeNats, but returns Word.

dimVal' :: forall n. KnownDim n => Word Source #

Similar to natVal from TypeNats, but returns Word.

typeableDim :: forall (n :: Nat). Typeable n => Dim n Source #

Construct a Dim n if there is an instance of Typeable n around.

Note: we can do this only for Nat-indexed dim, because the type XN m does not have enough information to create a dim at runtime.

sameDim :: forall (x :: Nat) (y :: Nat). Dim x -> Dim y -> Maybe (Dict (x ~ y)) Source #

We either get evidence that this function was instantiated with the same type-level numbers, or Nothing.

Note, this function works on Nat-indexed dimensions only, because Dim (XN x) does not have runtime evidence to infer x and `KnownDim x` does not imply `KnownDim (XN x)`.

sameDim' :: forall (x :: Nat) (y :: Nat). (KnownDim x, KnownDim y) => Maybe (Dict (x ~ y)) Source #

We either get evidence that this function was instantiated with the same type-level numbers, or Nothing.

lessOrEqDim :: forall (x :: Nat) (y :: Nat). Dim x -> Dim y -> Maybe (Dict (x <= y)) Source #

We either get evidence that x is not greater than y, or Nothing.

lessOrEqDim' :: forall (x :: Nat) (y :: Nat). (KnownDim x, KnownDim y) => Maybe (Dict (x <= y)) Source #

We either get evidence that x is not greater than y, or Nothing.

compareDim :: forall (a :: Nat) (b :: Nat). Dim a -> Dim b -> SOrdering (CmpNat a b) Source #

Ordering of dimension values.

Note: CmpNat forces type parameters to kind Nat; if you want to compare unknown XNats, use Ord instance of Dim.

compareDim' :: forall (a :: Nat) (b :: Nat). (KnownDim a, KnownDim b) => SOrdering (CmpNat a b) Source #

Ordering of dimension values.

Note: CmpNat forces type parameters to kind Nat; if you want to compare unknown XNats, use Ord instance of Dim.

constrainBy :: forall x p y. BoundedDim x => p x -> Dim y -> Maybe (Dim x) Source #

constrainDim with explicitly-passed constraining Dim to avoid AllowAmbiguousTypes.

relax :: forall (m :: Nat) (n :: Nat). (<=) m n => Dim (XN n) -> Dim (XN m) Source #

Decrease minimum allowed size of a Dim (XN x).

Simple Dim arithmetics

plusDim :: forall (n :: Nat) (m :: Nat). Dim n -> Dim m -> Dim (n + m) Source #

Same as `Prelude.(+)`. Pattern-matching against the result would produce the evindence KnownDim (n + m).

minusDim :: forall (n :: Nat) (m :: Nat). (<=) m n => Dim n -> Dim m -> Dim (n - m) Source #

Same as `Prelude.(-)`. Pattern-matching against the result would produce the evindence KnownDim (n - m).

minusDimM :: forall (n :: Nat) (m :: Nat). Dim n -> Dim m -> Maybe (Dim (n - m)) Source #

Similar to minusDim, but returns Nothing if the result would be negative. Pattern-matching against the result would produce the evindence KnownDim (n - m).

timesDim :: forall (n :: Nat) (m :: Nat). Dim n -> Dim m -> Dim (* n m) Source #

Same as `Prelude.(*)`. Pattern-matching against the result would produce the evindence KnownDim (n * m).

powerDim :: forall (n :: Nat) (m :: Nat). Dim n -> Dim m -> Dim ((^) n m) Source #

Same as `Prelude.(^)`. Pattern-matching against the result would produce the evindence KnownDim (n ^ m).

divDim :: forall (n :: Nat) (m :: Nat). Dim n -> Dim m -> Dim (Div n m) Source #

Same as div. Pattern-matching against the result would produce the evindence KnownDim (Div n m).

modDim :: forall (n :: Nat) (m :: Nat). Dim n -> Dim m -> Dim (Mod n m) Source #

Same as mod. Pattern-matching against the result would produce the evindence KnownDim (Mod n m).

log2Dim :: forall (n :: Nat). Dim n -> Dim (Log2 n) Source #

Returns log base 2 (round down). Pattern-matching against the result would produce the evindence KnownDim (Log2 n).

minDim :: forall (n :: Nat) (m :: Nat). Dim n -> Dim m -> Dim (Min n m) Source #

Same as min. Pattern-matching against the result would produce the evindence KnownDim (Min n m).

maxDim :: forall (n :: Nat) (m :: Nat). Dim n -> Dim m -> Dim (Max n m) Source #

Same as max. Pattern-matching against the result would produce the evindence KnownDim (Max n m).

Re-export part of Lits for convenience

type family CmpNat (a :: Nat) (b :: Nat) :: Ordering where ... #

Comparison of type-level naturals, as a function.

Since: base-4.7.0.0

data SOrdering :: Ordering -> Type where Source #

Singleton-style version of Ordering. Pattern-match againts its constructor to witness the result of type-level comparison.

Constructors

SLT :: SOrdering 'LT 
SEQ :: SOrdering 'EQ 
SGT :: SOrdering 'GT 

type family (a :: Nat) + (b :: Nat) :: Nat where ... infixl 6 #

Addition of type-level naturals.

Since: base-4.7.0.0

type family (a :: Nat) - (b :: Nat) :: Nat where ... infixl 6 #

Subtraction of type-level naturals.

Since: base-4.7.0.0

type family (a :: Nat) * (b :: Nat) :: Nat where ... infixl 7 #

Multiplication of type-level naturals.

Since: base-4.7.0.0

type family (a :: Nat) ^ (b :: Nat) :: Nat where ... infixr 8 #

Exponentiation of type-level naturals.

Since: base-4.7.0.0

type (<=) (a :: Nat) (b :: Nat) = LE a b (CmpNat a b) Source #

Comparison of type-level naturals, as a constraint.

type Min (a :: Nat) (b :: Nat) = Min' a b (CmpNat a b) Source #

Miminum among two type-level naturals.

type Max (a :: Nat) (b :: Nat) = Max' a b (CmpNat a b) Source #

Maximum among two type-level naturals.

Dims: a list of dimensions

type Dims = TypedList Dim :: [k] -> Type Source #

Type-level dimensionality.

data SomeDims Source #

Same as SomeNat, but for Dimensions: Hide all information about Dimensions inside

Constructors

forall (ns :: [Nat]). SomeDims (Dims ns) 

class Dimensions ds where Source #

Put runtime evidence of Dims value inside function constraints. Similar to KnownDim or KnownNat, but for lists of numbers.

Note, kind of the Dimensions list is usually Nat, restricted by KnownDim being also Nat-indexed (it is impossible to create a unique KnownDim (XN m) instance). Nevertheless, you can have KnownDim (N n), which is useful in some cases.

Methods

dims :: Dims ds Source #

Get dimensionality of a space at runtime, represented as a list of Dim.

Note, this function is supposed to be used with TypeApplications. For example, you can type:

>>> :set -XTypeApplications
>>> :set -XDataKinds
>>> :t dims @'[17, 12]
dims @'[17, 12] :: Dims '[17, 12]
>>> :t dims @'[]
dims @'[] :: Dims '[]
>>> :t dims @(Tail '[3,2,5,7])
dims @(Tail '[3,2,5,7]) :: Dims '[2, 5, 7]

Instances

Instances details
Dimensions ('[] :: [k]) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dims :: Dims '[] Source #

(KnownDim d, Dimensions ds) => Dimensions (d ': ds :: [k]) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dims :: Dims (d ': ds) Source #

withKnownXDims :: forall (ds :: [XNat]) (rep :: RuntimeRep) (r :: TYPE rep). Dimensions ds => ((Dimensions (DimsBound ds), ExactDims ds, All KnownDimType ds, FixedDims ds (DimsBound ds)) => r) -> r Source #

If you have Dimensions ds, then ds can only be [Nat] or a known type of [XNa]t (i.e. all N n). This function assures the type checker that this is indeed the case.

class (KnownDimKind (KindOfEl ds), All BoundedDim ds, RepresentableList ds, Dimensions (DimsBound ds), BoundedDimsTail ds) => BoundedDims ds where Source #

Get a minimal or exact bound of Dims.

This is a plural form of BoundedDim.

BoundedDims is a somewhat weaker form of Dimensions:

  • It is defined for both [Nat] and [XNat];
  • Instance of Dimensions ds always implies BoundedDims ds.

BoundedDims is a powerful inference tool: its instances do not require much, but it provides a lot via the superclass constraints.

Methods

dimsBound :: Dims (DimsBound ds) Source #

Plural form for dimBound

constrainDims :: forall ys. Dims ys -> Maybe (Dims ds) Source #

Plural form for constrainDim.

Given a Dims ys, test if its runtime value satisfies constraints imposed by BoundedDims xs, and returns it back coerced to Dims xs on success.

This function allows to guess safely individual dimension values, as well as the length of the dimension list. It returns Nothing if xs and ys have different length or if any of the values in ys are less than the corresponding values of xs.

Instances

Instances details
Dimensions ns => BoundedDims (ns :: [Nat]) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dimsBound :: Dims (DimsBound ns) Source #

constrainDims :: forall k (ys :: [k]). Dims ys -> Maybe (Dims ns) Source #

BoundedDims ('[] :: [XNat]) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dimsBound :: Dims (DimsBound '[]) Source #

constrainDims :: forall k (ys :: [k]). Dims ys -> Maybe (Dims '[]) Source #

(BoundedDim n, BoundedDims ns) => BoundedDims (n ': ns :: [XNat]) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

dimsBound :: Dims (DimsBound (n ': ns)) Source #

constrainDims :: forall k (ys :: [k]). Dims ys -> Maybe (Dims (n ': ns)) Source #

type family DimsBound (ds :: [k]) :: [Nat] where ... Source #

Minimal or exact bound of Dims. This is a plural form of DimBound.

Equations

DimsBound (ns :: [Nat]) = ns 
DimsBound ('[] :: [XNat]) = '[] 
DimsBound (n ': ns) = DimBound n ': DimsBound ns 

minimalDims :: forall ds. BoundedDims ds => Dims ds Source #

Minimal runtime Dims ds value that satifies the constraints imposed by the type signature of Dims ds (this is the exact dims for Nats and the minimal bound for XNats).

type family ExactDims (d :: [k]) :: Constraint where ... Source #

Every dim in a list is either Nat, or a known XNat (i.e. N n).

Equations

ExactDims (_ :: [Nat]) = () 
ExactDims (xs :: [XNat]) = xs ~ Map 'N (DimsBound xs) 

type family FixedDims (xns :: [XNat]) (ns :: [Nat]) :: Constraint where ... Source #

Constrain Nat dimensions hidden behind XNats. This is a link connecting the two types of type-level dims; you often need it to convert Dims, Idxs, and data.

Equations

FixedDims '[] ns = ns ~ '[] 
FixedDims (xn ': xns) ns = (ns ~ (Head ns ': Tail ns), FixedDim xn (Head ns), FixedDims xns (Tail ns)) 

inferFixedDims :: forall (xns :: [XNat]) (ns :: [Nat]). All KnownDimType xns => Dims xns -> Dims ns -> Maybe (Dict (FixedDims xns ns)) Source #

Try to instantiate the FixedDims constraint given two Dims lists.

The first Dims is assumed to be the output of minimalDims, i.e. listDims xns == toList (listDims xns).

If you input a list that is not equal to its type-level DimsBound, you will just have a lower chance to get Just Dict result.

inferExactFixedDims :: forall (ds :: [XNat]). ExactDims ds => Dims (DimsBound ds) -> Dict (All KnownDimType ds, FixedDims ds (DimsBound ds)) Source #

Infer FixedDims if you know that all of dims are exact (d ~ N n). This function is totally safe and faithful.

data TypedList (f :: k -> Type) (xs :: [k]) where Source #

Type-indexed list

Bundled Patterns

pattern Dims :: forall ds. KnownDimKind (KindOfEl ds) => forall (ns :: [Nat]). (ds ~~ ns, Dimensions ns) => Dims ds

O(1) Pattern-matching against this constructor brings a Dimensions instance into the scope. Thus, you can do arbitrary operations on your dims and use this pattern at any time to reconstruct the class instance at runtime.

pattern XDims :: forall ds. KnownDimKind (KindOfEl ds) => forall (ns :: [Nat]). FixedDims ds ns => Dims ns -> Dims ds

O(n) 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 Dims at runtime; for example, reading a list of dimensions from a file.

pattern KnownDims :: forall (ds :: [Nat]). () => (All KnownDim ds, All BoundedDim ds, RepresentableList ds, Dimensions ds) => Dims ds

O(Length ds) A heavy weapon against all sorts of type errors

pattern U :: forall (k :: Type) (f :: k -> Type) (xs :: [k]). () => xs ~ '[] => TypedList f xs

Zero-length type list

pattern (:*) :: forall f xs. () => forall y ys. xs ~ (y ': ys) => f y -> TypedList f ys -> TypedList f xs infixr 5

Constructing a type-indexed list

pattern Empty :: forall (k :: Type) (f :: k -> Type) (xs :: [k]). () => xs ~ '[] => TypedList f xs

Zero-length type list; synonym to U.

pattern TypeList :: forall xs. () => RepresentableList xs => TypeList 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 f xs. () => forall y ys. xs ~ (y ': ys) => f y -> TypedList f ys -> TypedList f xs

Constructing a type-indexed list in the canonical way

pattern Snoc :: forall f xs. () => forall sy y. SnocList sy y xs => TypedList f sy -> f y -> TypedList f xs

Constructing a type-indexed list from the other end

pattern Reverse :: forall f xs. () => forall sx. ReverseList xs sx => TypedList f sx -> TypedList f xs

Reverse a typed list

Instances

Instances details
(RepresentableList xs, All Bounded xs) => Bounded (Tuple xs) Source # 
Instance details

Defined in Numeric.Tuple.Strict

Methods

minBound :: Tuple xs #

maxBound :: Tuple xs #

(RepresentableList xs, All Bounded xs) => Bounded (Tuple xs) Source # 
Instance details

Defined in Numeric.Tuple.Lazy

Methods

minBound :: Tuple xs #

maxBound :: Tuple xs #

All Eq xs => Eq (Tuple xs) Source # 
Instance details

Defined in Numeric.Tuple.Strict

Methods

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

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

All Eq xs => Eq (Tuple xs) Source # 
Instance details

Defined in Numeric.Tuple.Lazy

Methods

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

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

(All Eq xs, All Ord xs) => Ord (Tuple xs) Source #

Lexicorgaphic ordering; same as normal Haskell lists.

Instance details

Defined in Numeric.Tuple.Strict

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) Source #

Lexicorgaphic ordering; same as normal Haskell lists.

Instance details

Defined in Numeric.Tuple.Lazy

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 Read xs, RepresentableList xs) => Read (Tuple xs) Source # 
Instance details

Defined in Numeric.Tuple.Strict

(All Read xs, RepresentableList xs) => Read (Tuple xs) Source # 
Instance details

Defined in Numeric.Tuple.Lazy

All Show xs => Show (Tuple xs) Source # 
Instance details

Defined in Numeric.Tuple.Strict

Methods

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

show :: Tuple xs -> String #

showList :: [Tuple xs] -> ShowS #

All Show xs => Show (Tuple xs) Source # 
Instance details

Defined in Numeric.Tuple.Lazy

Methods

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

show :: Tuple xs -> String #

showList :: [Tuple xs] -> ShowS #

All Semigroup xs => Semigroup (Tuple xs) Source # 
Instance details

Defined in Numeric.Tuple.Strict

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) Source # 
Instance details

Defined in Numeric.Tuple.Lazy

Methods

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

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

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

(RepresentableList xs, All Semigroup xs, All Monoid xs) => Monoid (Tuple xs) Source # 
Instance details

Defined in Numeric.Tuple.Strict

Methods

mempty :: Tuple xs #

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

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

(RepresentableList xs, All Semigroup xs, All Monoid xs) => Monoid (Tuple xs) Source # 
Instance details

Defined in Numeric.Tuple.Lazy

Methods

mempty :: Tuple xs #

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

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

BoundedDims ds => Bounded (Idxs ds) Source # 
Instance details

Defined in Numeric.Dimensions.Idx

Methods

minBound :: Idxs ds #

maxBound :: Idxs ds #

Dimensions ds => Enum (Idxs ds) Source #

ds must be fixed (either [Nat] or all (N n)) to know exact bounds in each dimension.

Instance details

Defined in Numeric.Dimensions.Idx

Methods

succ :: Idxs ds -> Idxs ds #

pred :: Idxs ds -> Idxs ds #

toEnum :: Int -> Idxs ds #

fromEnum :: Idxs ds -> Int #

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

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

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

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

Eq (Dims ds) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

(==) :: Dims ds -> Dims ds -> Bool #

(/=) :: Dims ds -> Dims ds -> Bool #

Eq (Dims ds) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

(==) :: Dims ds -> Dims ds -> Bool #

(/=) :: Dims ds -> Dims ds -> Bool #

Eq (Idxs xs) Source # 
Instance details

Defined in Numeric.Dimensions.Idx

Methods

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

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

Ord (Dims ds) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

compare :: Dims ds -> Dims ds -> Ordering #

(<) :: Dims ds -> Dims ds -> Bool #

(<=) :: Dims ds -> Dims ds -> Bool #

(>) :: Dims ds -> Dims ds -> Bool #

(>=) :: Dims ds -> Dims ds -> Bool #

max :: Dims ds -> Dims ds -> Dims ds #

min :: Dims ds -> Dims ds -> Dims ds #

Ord (Dims ds) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

compare :: Dims ds -> Dims ds -> Ordering #

(<) :: Dims ds -> Dims ds -> Bool #

(<=) :: Dims ds -> Dims ds -> Bool #

(>) :: Dims ds -> Dims ds -> Bool #

(>=) :: Dims ds -> Dims ds -> Bool #

max :: Dims ds -> Dims ds -> Dims ds #

min :: Dims ds -> Dims ds -> Dims ds #

Ord (Idxs xs) Source #

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 compare rule, as for Dims. This is also consistent with offsets:

sort == sortOn fromEnum
Instance details

Defined in Numeric.Dimensions.Idx

Methods

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

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

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

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

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

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

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

BoundedDims xs => Read (Dims xs) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

BoundedDims xs => Read (Idxs xs) Source # 
Instance details

Defined in Numeric.Dimensions.Idx

Show (Dims xs) Source # 
Instance details

Defined in Numeric.Dimensions.Dim

Methods

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

show :: Dims xs -> String #

showList :: [Dims xs] -> ShowS #

Show (Idxs xs) Source # 
Instance details

Defined in Numeric.Dimensions.Idx

Methods

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

show :: Idxs xs -> String #

showList :: [Idxs xs] -> ShowS #

(Typeable k, Typeable f, Typeable xs, All Data (Map f xs)) => Data (TypedList f xs) Source #

Term-level structure of a TypedList f xs is fully determined by its type Typeable xs. Thus, gunfold does not use its last argument (Constr) at all, relying on the structure of the type parameter.

Instance details

Defined in Numeric.TypedList

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TypedList f xs -> c (TypedList f xs) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (TypedList f xs) #

toConstr :: TypedList f xs -> Constr #

dataTypeOf :: TypedList f xs -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (TypedList f xs)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (TypedList f xs)) #

gmapT :: (forall b. Data b => b -> b) -> TypedList f xs -> TypedList f xs #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TypedList f xs -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TypedList f xs -> r #

gmapQ :: (forall d. Data d => d -> u) -> TypedList f xs -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TypedList f xs -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TypedList f xs -> m (TypedList f xs) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TypedList f xs -> m (TypedList f xs) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TypedList f xs -> m (TypedList f xs) #

Generic (TypedList f xs) Source # 
Instance details

Defined in Numeric.TypedList

Associated Types

type Rep (TypedList f xs) :: Type -> Type #

Methods

from :: TypedList f xs -> Rep (TypedList f xs) x #

to :: Rep (TypedList f xs) x -> TypedList f xs #

type Rep (TypedList f xs) Source # 
Instance details

Defined in Numeric.TypedList

type Rep (TypedList f xs)

typeableDims :: forall (ds :: [Nat]). Typeable ds => Dims ds Source #

Construct a Dims ds if there is an instance of Typeable ds around.

inferTypeableDims :: forall (ds :: [Nat]). Dims ds -> Dict (Typeable ds) Source #

Dims (ds :: [Nat]) is always Typeable.

listDims :: forall xs. Dims xs -> [Word] Source #

O(1) Convert Dims xs to a plain haskell list of dimension sizes.

Note, for XNat-indexed list it returns actual content dimensions, not the constraint numbers (XN m)

someDimsVal :: [Word] -> SomeDims Source #

Convert a plain haskell list of dimension sizes into an unknown type-level dimensionality O(1).

totalDim :: forall xs. Dims xs -> Word Source #

Product of all dimension sizes O(Length xs).

totalDim' :: forall xs. Dimensions xs => Word Source #

Product of all dimension sizes O(Length xs).

sameDims :: forall (as :: [Nat]) (bs :: [Nat]). Dims as -> Dims bs -> Maybe (Dict (as ~ bs)) Source #

We either get evidence that this function was instantiated with the same type-level Dimensions, or Nothing O(Length xs).

sameDims' :: forall (as :: [Nat]) (bs :: [Nat]) (p :: [Nat] -> Type) (q :: [Nat] -> Type). (Dimensions as, Dimensions bs) => p as -> q bs -> Maybe (Dict (as ~ bs)) Source #

We either get evidence that this function was instantiated with the same type-level Dimensions, or Nothing O(Length xs).

inSpaceOf :: forall ds p q. p ds -> q ds -> p ds Source #

Restricted version of const, similar to asProxyTypeOf; to be used on such implicit functions as dims, dimsBound etc.

stripPrefixDims :: forall (xs :: [Nat]) (ys :: [Nat]). Dims xs -> Dims ys -> Maybe (Dims (StripPrefix xs ys)) Source #

Drop the given prefix from a Dims list. It returns Nothing if the list did not start with the prefix given, or Just the Dims after the prefix, if it does.

stripSuffixDims :: forall (xs :: [Nat]) (ys :: [Nat]). Dims xs -> Dims ys -> Maybe (Dims (StripSuffix xs ys)) Source #

Drop the given suffix from a Dims list. It returns Nothing if the list did not end with the suffix given, or Just the Dims before the suffix, if it does.

Re-export type list

class RepresentableList xs where Source #

Representable type lists. Allows getting type information about list structure at runtime.

Methods

tList :: TypeList xs Source #

Get type-level constructed list

Instances

Instances details
RepresentableList ('[] :: [k]) Source # 
Instance details

Defined in Numeric.TypedList

Methods

tList :: TypeList '[] Source #

RepresentableList xs => RepresentableList (x ': xs :: [k]) Source # 
Instance details

Defined in Numeric.TypedList

Methods

tList :: TypeList (x ': xs) Source #

type TypeList = TypedList Proxy :: [k] -> Type Source #

A list of type proxies

types :: forall f xs. TypedList f xs -> TypeList xs Source #

Get a constructible TypeList from any other TypedList; Pattern matching agains the result brings RepresentableList constraint into the scope:

case types ts of TypeList -> ...

order :: forall f xs. TypedList f xs -> Dim (Length xs) Source #

Return the number of elements in a TypedList (same as length).

order' :: forall xs. RepresentableList xs => Dim (Length xs) Source #

Return the number of elements in a type list xs bound by a constraint RepresentableList xs (same as order, but takes no value arguments).

type KindOf (t :: k) = k Source #

Get the kind of a given type. Useful when we don't want to introduce another type parameter into a type signature (because the kind is determined by the type), but need to have some constraints on the type's kind.

type KindOfEl (ts :: [k]) = k Source #

Get the kind of a given list type. Useful when we don't want to introduce another type parameter into a type signature (because the kind is determined by the type), but need to have some constraints on the type's kind.