| Portability | portable |
|---|---|
| Stability | provisional |
| Maintainer | ross@soi.city.ac.uk |
Data.YAP.Quantity
Description
An example instance of the new 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 |