dimensional-1.5: Statically checked physical dimensions

Copyright | Copyright (C) 2006-2018 Bjorn Buckwalter
License | BSD3
Maintainer | bjorn@buckwalter.se
Stability | Stable
Portability | GHC only
Safe Haskell | Safe-Inferred
Language | Haskell2010

Extensions

- MonoLocalBinds
- TypeFamilies
- ConstraintKinds
- DataKinds
- DeriveDataTypeable
- DeriveGeneric
- KindSignatures
- TypeOperators
- ExplicitNamespaces

Numeric.Units.Dimensional.Variants

Description

Provides a type level representation of `Variant`s of dimensional values, which may be quantities or units.

Synopsis

- data Variant
  - = DQuantity ExactPi'
  - | DUnit Metricality
- data Metricality
  - = Metric
  - | NonMetric
- type family (v1 :: Variant) * (v2 :: Variant) :: Variant where ...
- type family (v1 :: Variant) / (v2 :: Variant) :: Variant where ...
- type family Weaken (v :: Variant) :: Variant where ...
- type CompatibleVariants v1 v2 = 'True ~ AreCompatible v1 v2

# Documentation

data Variant Source #

The kind of variants of dimensional values.

Constructors

DQuantity ExactPi' | The value is a quantity, stored as an `ExactPi` multiple of its value in its dimension's SI coherent unit.
DUnit Metricality | The value is a unit, possibly a `Metric` unit.

#### Instances

Instances details

Generic Variant Source # |
Instance details Defined in Numeric.Units.Dimensional.Variants Associated Types type Rep Variant :: Type -> Type Source # Methods from :: Variant -> Rep Variant x Source # to :: Rep Variant x -> Variant Source #
type Rep Variant Source # |

Instance details

Defined in Numeric.Units.Dimensional.Variants

type Rep Variant = D1 ('MetaData "Variant" "Numeric.Units.Dimensional.Variants" "dimensional-1.5-JocKE6CJzn4394JHdrLVJ" 'False) (C1 ('MetaCons "DQuantity" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ExactPi')) :+: C1 ('MetaCons "DUnit" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Metricality)))

data Metricality Source #

Encodes whether a unit is a metric unit, that is, whether it can be combined with a metric prefix to form a related unit.

Constructors

Metric | Capable of receiving a metric prefix.
NonMetric | Incapable of receiving a metric prefix.

#### Instances

Instances details

Data Metricality Source # |

Instance details

Defined in Numeric.Units.Dimensional.Variants

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Metricality -> c Metricality Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Metricality Source #

toConstr :: Metricality -> Constr Source #

dataTypeOf :: Metricality -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Metricality) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Metricality) Source #

gmapT :: (forall b. Data b => b -> b) -> Metricality -> Metricality Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Metricality -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Metricality -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Metricality -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Metricality -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Metricality -> m Metricality Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Metricality -> m Metricality Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Metricality -> m Metricality Source #

Generic Metricality Source # |
Instance details Defined in Numeric.Units.Dimensional.Variants Associated Types type Rep Metricality :: Type -> Type Source # Methods from :: Metricality -> Rep Metricality x Source # to :: Rep Metricality x -> Metricality Source #
NFData Metricality Source # |
Instance details Defined in Numeric.Units.Dimensional.Variants Methods rnf :: Metricality -> () Source #
Eq Metricality Source # |
Instance details Defined in Numeric.Units.Dimensional.Variants Methods (==) :: Metricality -> Metricality -> Bool Source # (/=) :: Metricality -> Metricality -> Bool Source #
Ord Metricality Source # |

Instance details

Defined in Numeric.Units.Dimensional.Variants

Methods

compare :: Metricality -> Metricality -> Ordering Source #

(<) :: Metricality -> Metricality -> Bool Source #

(<=) :: Metricality -> Metricality -> Bool Source #

(>) :: Metricality -> Metricality -> Bool Source #

(>=) :: Metricality -> Metricality -> Bool Source #

max :: Metricality -> Metricality -> Metricality Source #

min :: Metricality -> Metricality -> Metricality Source #

type Rep Metricality Source # |
Instance details Defined in Numeric.Units.Dimensional.Variants type Rep Metricality = D1 ('MetaData "Metricality" "Numeric.Units.Dimensional.Variants" "dimensional-1.5-JocKE6CJzn4394JHdrLVJ" 'False) (C1 ('MetaCons "Metric" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NonMetric" 'PrefixI 'False) (U1 :: Type -> Type))

type family (v1 :: Variant) * (v2 :: Variant) :: Variant where ... infixl 7 Source #

Forms the product of two `Variant`s.

The product of units is a non-metric unit.

The product of quantities is a quantity.

Equations

('DUnit m1) * ('DUnit m2) = 'DUnit 'NonMetric |
('DQuantity s1) * ('DQuantity s2) = 'DQuantity (s1 * s2) |

type family (v1 :: Variant) / (v2 :: Variant) :: Variant where ... Source #

Forms the quotient of two `Variant`s.

The quotient of units is a non-metric unit.

The quotient of quantities is a quantity.

Equations

('DUnit m1) / ('DUnit m2) = 'DUnit 'NonMetric |
('DQuantity s1) / ('DQuantity s2) = 'DQuantity (s1 / s2) |

type family Weaken (v :: Variant) :: Variant where ... Source #

Weakens a `Variant` by forgetting possibly uninteresting type-level information.

Equations

Weaken ('DQuantity s) = 'DQuantity s |
Weaken ('DUnit m) = 'DUnit 'NonMetric |

type CompatibleVariants v1 v2 = 'True ~ AreCompatible v1 v2 Source #

Two `Variant`s are compatible when dimensional values of the first may be converted into the second merely by changing the representation of their values.