Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
A numeric type to manage engineering units.
Provides automatic unit conversion:
> print $ value (1 * h + 1 * min') s -- Time in seconds of 1 hour + 1 minute. 3660.0
Automatic unit reduction:
> print $ value (20 * gpm * 10 * min') gal -- Note the minutes cancel each other out. 200.0
And consistency checking:
> print $ value (22 * mph + 3 gal) mph -- Note that speed (m/s) is inconsistent with volume (m^3). *** Exception: Incompatible units: [M]/[S] /= [M,M,M]/[]
And defining new units is easy:
-- | Millimeters, a measure of distance, is 1/1000 of a meter. mm :: Value mm = 0.001 * m
-- | Joules, a measure of energy, is one newton meter. j :: Value j = n * m
- data Value
- value :: Value -> Value -> Double
- m :: Value
- cm :: Value
- mm :: Value
- km :: Value
- in' :: Value
- ft :: Value
- mi :: Value
- cm2 :: Value
- in2 :: Value
- cm3 :: Value
- ml :: Value
- l :: Value
- in3 :: Value
- gal :: Value
- kg :: Value
- g :: Value
- mg :: Value
- n :: Value
- lbs :: Value
- rev :: Value
- mph :: Value
- kph :: Value
- rpm :: Value
- s :: Value
- ns :: Value
- us :: Value
- ms :: Value
- min' :: Value
- h :: Value
- j :: Value
- btu :: Value
- hp :: Value
- w :: Value
- kw :: Value
- psi :: Value
- bar :: Value
- gpm :: Value
- lpm :: Value
- s2 :: Value
- radsPerRev :: Value