| Copyright | (c) Ross Paterson 2011 |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | [email protected] |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.YAP.Quantity
Description
An example instance of the algebraic classes: numeric quantities with unit types. You can only compare and add quantities that use the same units.
Documentation
Quantities of a numeric type a, in units encoded by the phantom
type parameter u.
For example, types for counting apples and oranges can be defined as:
data Apple data Orange type Apples = Quantity Apple Int type Oranges = Quantity Orange Int
You can't compare Apples with Oranges (or add them).
You can add Apples to Apples, but not multiply them.
A full dimensional system keeping track of units while modelling multiplication and division will require type-level functions.
Constructors
| Quantity a |
Instances
| Read a => Read (Quantity u a) Source # | |
| Show a => Show (Quantity u a) Source # | |
| Eq a => Eq (Quantity u a) Source # | |
| Ord a => Ord (Quantity u a) Source # | |
Defined in Data.YAP.Quantity | |
| AbelianGroup a => AbelianGroup (Quantity u a) Source # | |
| AdditiveMonoid a => AdditiveMonoid (Quantity u a) Source # | |