packages feed

units-defs 1.0.1 → 2.2.1

raw patch · 36 files changed

Files

CHANGES.md view
@@ -1,3 +1,53 @@+Version 2.2.1+-------------+* Actually export Imperial units, along with bugfixes (thanks to @Bebere).+* Export Eurocard units (thanks to @mlang).++Version 2.2+-----------++* Add support for new PlaneAngle and SolidAngle dimensions, thanks+to @gittywithexcitement.++Version 2.1.0.1+---------------++* Update .cabal file to export Data.Units.Astronomical.++Version 2.1+-----------++* Add support for Imperial and astronomical units, thanks to @Bebere.++Version 2.0.1.1+---------------++* Drop 7.8 support, fixing warnings on 8.0.++Version 2.0.1+-------------++* Added the universal gravitational constant, thanks to @hesiod.++Version 2.0.0.1+---------------++* Typos in documentation. Thanks to Doug Burke for a pull request!++Version 2.0+-----------++* Full re-organization of modules.+* Addition of US customary units, CGS units, and a few other gubbins.++Version 1.1+-----------++* Added `si` parser.+* Moved `DefaultUnitOfDim` instances from `SI.MonoTypes` to `SI.Mono`. This allows+  client code to import the monomorphic types without getting these instances. But,+  it may mean that your imports have to change.+ Version 1.0.1 ------------- 
+ Data/Constants/Math.hs view
@@ -0,0 +1,19 @@+-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Constants.Math+-- Copyright   :  (C) 2014 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- Approximates mathematical constants as 'Rational's+-----------------------------------------------------------------------------++module Data.Constants.Math where++piR :: Rational+piR = 3.1415926535897932384626433832795028841971693993751058209749445923078164++eR :: Rational+eR = 2.71828182845904523536028747135266249775724709369995957496696762772407663
+ Data/Constants/Mechanics.hs view
@@ -0,0 +1,32 @@+{-# LANGUAGE TypeOperators, ConstraintKinds, TemplateHaskell #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Constants.Mechanics+-- Copyright   :  (C) 2014 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- This file defines dimensioned physical constants, useful in mechanics.+--+-- The names used are a short description of the constant followed by its+-- usual symbol, separated by an underscore. For non-Latin symbols, the+-- Latin-lettered transliteration of the symbol name is used.+-----------------------------------------------------------------------------++module Data.Constants.Mechanics where++import Data.Metrology.Poly+import Data.Metrology.SI.Poly+import Data.Metrology.TH++-- | Acceleration at Earth's surface due to gravity.+declareConstant "gravity_g" 9.80665 [t| Meter :/ Second :^ Two |]++-- | Gravitational constant (value recommended by CODATA, see the+-- <http://arxiv.org/abs/1507.07956 arXiv> paper)+declareConstant "gravity_G" 6.6740831e-11+  [t| (Meter :^ Three) :* ((Kilo :@ Gram) :^ MOne) :* (Second :^ MTwo) |]+  -- Thanks to @hesiod, PR #13
+ Data/Dimensions/SI.hs view
@@ -0,0 +1,74 @@+{-# LANGUAGE TypeOperators, TemplateHaskell #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Dimensions.SI+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- This module defines SI dimensions. The names of SI dimensions conform to+-- <http://www.bipm.org/utils/common/documents/jcgm/JCGM_200_2012.pdf>.+-----------------------------------------------------------------------------++module Data.Dimensions.SI where++import Data.Metrology.Poly+import Data.Metrology.TH++declareDimension "Length"+declareDimension "Mass"+declareDimension "Time"+declareDimension "Current"+declareDimension "Temperature"+declareDimension "AmountOfSubstance"+declareDimension "LuminousIntensity"++-- | A plane angle is dimensionless; alternatively, it has dimension+-- length/length. It would be wrong to divide 2 meters by 1+-- meter and conclude that the quantity is 2 radians or degrees. To make+-- plane angle safe to use, we define it as a fundamental dimension.+declareDimension "PlaneAngle"++-- | As we did for plane angle, we must make solid angle a fundamental+-- dimension to avoid programming mistakes.+-- +-- A solid angle is a measure of the amount of the field of view from some+-- particular point that a given object covers.+declareDimension "SolidAngle"++type Area                = Length            :^ Two+type Volume              = Length            :^ Three+type Velocity            = Length            :/ Time+type Acceleration        = Velocity          :/ Time+type Wavenumber          = Length            :^ MOne+type Density             = Mass              :/ Volume+type SurfaceDensity      = Mass              :/ Area+type SpecificVolume      = Volume            :/ Mass+type CurrentDensity      = Current           :/ Area+type MagneticStrength    = Current           :/ Length+type Concentration       = AmountOfSubstance        :/ Volume+type Luminance           = LuminousIntensity        :/ Area++type Frequency           = Time              :^ MOne+type Force               = Mass              :* Acceleration+type Pressure            = Force             :/ Area+type Energy              = Force             :* Length+type Power               = Energy            :/ Time+type Charge              = Current           :* Time+type ElectricPotential   = Power             :/ Current+type Capacitance         = Charge            :/ ElectricPotential+type Resistance          = ElectricPotential :/ Current+type Conductance         = Current           :/ ElectricPotential+type MagneticFlux        = ElectricPotential :* Time+type MagneticFluxDensity = MagneticFlux      :/ Area+type Inductance          = MagneticFlux      :/ Current+type LuminousFlux        = LuminousIntensity+type Illuminance         = LuminousIntensity :/ Area+type Kerma               = Area              :/ (Time :^ Two)+type CatalyticActivity   = AmountOfSubstance :/ Time++type Momentum            = Mass              :* Velocity+type AngularVelocity     = PlaneAngle        :/ Time
Data/Metrology/SI.hs view
@@ -3,7 +3,7 @@ -- Module      :  Data.Metrology.SI -- Copyright   :  (C) 2013 Richard Eisenberg -- License     :  BSD-style (see LICENSE)--- Maintainer  :  Richard Eisenberg (eir@cis.upenn.edu)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu) -- Stability   :  experimental -- Portability :  non-portable --@@ -17,9 +17,7 @@ -----------------------------------------------------------------------------  module Data.Metrology.SI (-  module Data.Metrology.SI.Mono+  module Data.Metrology.SI.Mono,   ) where  import Data.Metrology.SI.Mono--
− Data/Metrology/SI/Dims.hs
@@ -1,72 +0,0 @@-{-# LANGUAGE TypeOperators #-}---------------------------------------------------------------------------------- |--- Module      :  Data.Metrology.SI.Dims--- Copyright   :  (C) 2013 Richard Eisenberg--- License     :  BSD-style (see LICENSE)--- Maintainer  :  Richard Eisenberg (eir@cis.upenn.edu)--- Stability   :  experimental--- Portability :  non-portable------ This module defines SI dimensions. The names of SI dimensions conform to--- <http://www.bipm.org/utils/common/documents/jcgm/JCGM_200_2012.pdf>.--------------------------------------------------------------------------------module Data.Metrology.SI.Dims where--import Data.Metrology--data Length = Length-instance Dimension Length--data Mass = Mass-instance Dimension Mass--data Time = Time-instance Dimension Time--data Current = Current-instance Dimension Current--data Temperature = Temperature-instance Dimension Temperature--data AmountOfSubstance = AmountOfSubstance-instance Dimension AmountOfSubstance--data LuminousIntensity = LuminousIntensity-instance Dimension LuminousIntensity--type Area                = Length            :^ Two-type Volume              = Length            :^ Three-type Velocity            = Length            :/ Time-type Acceleration        = Velocity          :/ Time-type Wavenumber          = Length            :^ MOne-type Density             = Mass              :/ Volume-type SurfaceDensity      = Mass              :/ Area-type SpecificVolume      = Volume            :/ Mass-type CurrentDensity      = Current           :/ Area-type MagneticStrength    = Current           :/ Length-type Concentration       = AmountOfSubstance          :/ Volume-type Luminance           = LuminousIntensity        :/ Area--type Frequency           = Time              :^ MOne-type Force               = Mass              :* Acceleration-type Pressure            = Force             :/ Area-type Energy              = Force             :* Length-type Power               = Energy            :/ Time-type Charge              = Current           :* Time-type ElectricPotential   = Power             :/ Current-type Capacitance         = Charge            :/ ElectricPotential-type Resistance          = ElectricPotential :/ Current-type Conductance         = Current           :/ ElectricPotential-type MagneticFlux        = ElectricPotential :* Time-type MagneticFluxDensity = MagneticFlux      :/ Area-type Inductance          = MagneticFlux      :/ Current-type LuminousFlux        = LuminousIntensity-type Illuminance         = LuminousIntensity :/ Area-type Kerma               = Area              :/ (Time :^ Two)-type CatalyticActivity   = AmountOfSubstance :/ Time--type Momentum            = Mass              :* Velocity
Data/Metrology/SI/Mono.hs view
@@ -1,25 +1,42 @@+{-# LANGUAGE TypeOperators, TypeFamilies #-}+ ----------------------------------------------------------------------------- -- | -- Module      :  Data.Metrology.SI.Mono -- Copyright   :  (C) 2013 Richard Eisenberg -- License     :  BSD-style (see LICENSE)--- Maintainer  :  Richard Eisenberg (eir@cis.upenn.edu)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu) -- Stability   :  experimental -- Portability :  non-portable -- -- This module exports definitions for the SI system, with the intent -- of using these definitions in a monomorphic manner -- that is,--- with the DefaultLCSU.+-- with the DefaultLCSU. The difference between this module and+-- 'Data.Metrology.SI.MonoTypes' is that this module also exports+-- instances of 'DefaultUnitOfDim', necessary for use with+-- 'DefaultLCSU'. -----------------------------------------------------------------------------  module Data.Metrology.SI.Mono (   module Data.Metrology.SI.MonoTypes,-  module Data.Metrology.SI.Units,-  module Data.Metrology.SI.Prefixes+  module Data.Units.SI,+  module Data.Units.SI.Prefixes,+  module Data.Units.SI.Parser   ) where  import Data.Metrology.SI.MonoTypes-import Data.Metrology.SI.Units-import Data.Metrology.SI.Prefixes-+import Data.Units.SI+import Data.Units.SI.Prefixes+import qualified Data.Dimensions.SI as D+import Data.Metrology+import Data.Units.SI.Parser +type instance DefaultUnitOfDim D.Length            = Meter+type instance DefaultUnitOfDim D.Mass              = Kilo :@ Gram+type instance DefaultUnitOfDim D.Time              = Second+type instance DefaultUnitOfDim D.Current           = Ampere+type instance DefaultUnitOfDim D.Temperature       = Kelvin+type instance DefaultUnitOfDim D.AmountOfSubstance = Mole+type instance DefaultUnitOfDim D.LuminousIntensity = Lumen+type instance DefaultUnitOfDim D.PlaneAngle        = Radian+type instance DefaultUnitOfDim D.SolidAngle        = Steradian
Data/Metrology/SI/MonoTypes.hs view
@@ -5,28 +5,19 @@ -- Module      :  Data.Metrology.SI.MonoTypes -- Copyright   :  (C) 2013 Richard Eisenberg -- License     :  BSD-style (see LICENSE)--- Maintainer  :  Richard Eisenberg (eir@cis.upenn.edu)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu) -- Stability   :  experimental -- Portability :  non-portable -- -- This module defines type synonyms for SI units, using a Double as the--- internal representation.+-- internal representation. This module /does not/ export instances of+-- 'DefaultUnitOfDim'. Use 'Data.Metrology.SI.Mono' for that. -----------------------------------------------------------------------------  module Data.Metrology.SI.MonoTypes where  import Data.Metrology-import Data.Metrology.SI.Units-import Data.Metrology.SI.Prefixes ( Kilo )-import qualified Data.Metrology.SI.Dims as D--type instance DefaultUnitOfDim D.Length            = Meter-type instance DefaultUnitOfDim D.Mass              = Kilo :@ Gram-type instance DefaultUnitOfDim D.Time              = Second-type instance DefaultUnitOfDim D.Current           = Ampere-type instance DefaultUnitOfDim D.Temperature       = Kelvin-type instance DefaultUnitOfDim D.AmountOfSubstance = Mole-type instance DefaultUnitOfDim D.LuminousIntensity = Lumen+import qualified Data.Dimensions.SI as D  type Length              = MkQu_D D.Length type Mass                = MkQu_D D.Mass@@ -35,6 +26,8 @@ type Temperature         = MkQu_D D.Temperature type AmountOfSubstance   = MkQu_D D.AmountOfSubstance type LuminousIntensity   = MkQu_D D.LuminousIntensity+type PlaneAngle          = MkQu_D D.PlaneAngle+type SolidAngle          = MkQu_D D.SolidAngle  type Area                = MkQu_D D.Area type Volume              = MkQu_D D.Volume@@ -66,3 +59,4 @@ type Kerma               = MkQu_D D.Kerma type CatalyticActivity   = MkQu_D D.CatalyticActivity type Momentum            = MkQu_D D.Momentum+type AngularVelocity     = MkQu_D D.AngularVelocity
Data/Metrology/SI/Poly.hs view
@@ -5,7 +5,7 @@ -- Module      :  Data.Metrology.SI.Poly -- Copyright   :  (C) 2013 Richard Eisenberg -- License     :  BSD-style (see LICENSE)--- Maintainer  :  Richard Eisenberg (eir@cis.upenn.edu)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu) -- Stability   :  experimental -- Portability :  non-portable --@@ -17,15 +17,17 @@ module Data.Metrology.SI.Poly (   SI,   module Data.Metrology.SI.PolyTypes,-  module Data.Metrology.SI.Prefixes,-  module Data.Metrology.SI.Units+  module Data.Units.SI.Prefixes,+  module Data.Units.SI,+  module Data.Units.SI.Parser   ) where  import Data.Metrology.SI.PolyTypes-import Data.Metrology.SI.Prefixes-import Data.Metrology.SI.Units-import qualified Data.Metrology.SI.Dims as D+import Data.Units.SI.Prefixes+import Data.Units.SI+import qualified Data.Dimensions.SI as D import Data.Metrology+import Data.Units.SI.Parser  type SI = MkLCSU '[ (D.Length, Meter)                   , (D.Mass, Kilo :@ Gram)@@ -34,4 +36,6 @@                   , (D.Temperature, Kelvin)                   , (D.AmountOfSubstance, Mole)                   , (D.LuminousIntensity, Lumen)+                  , (D.PlaneAngle, Radian)+                  , (D.SolidAngle, Steradian)                   ]
Data/Metrology/SI/PolyTypes.hs view
@@ -5,7 +5,7 @@ -- Module      :  Data.Metrology.SI.PolyTypes -- Copyright   :  (C) 2013 Richard Eisenberg -- License     :  BSD-style (see LICENSE)--- Maintainer  :  Richard Eisenberg (eir@cis.upenn.edu)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu) -- Stability   :  experimental -- Portability :  non-portable --@@ -16,43 +16,46 @@ module Data.Metrology.SI.PolyTypes where  import Data.Metrology-import qualified Data.Metrology.SI.Dims as D+import qualified Data.Dimensions.SI as D -type Length              = MkQu_DLN D.Length              -type Mass                = MkQu_DLN D.Mass                -type Time                = MkQu_DLN D.Time                -type Current             = MkQu_DLN D.Current             -type Temperature         = MkQu_DLN D.Temperature         -type AmountOfSubstance   = MkQu_DLN D.AmountOfSubstance   -type LuminousIntensity   = MkQu_DLN D.LuminousIntensity   +type Length              = MkQu_DLN D.Length+type Mass                = MkQu_DLN D.Mass+type Time                = MkQu_DLN D.Time+type Current             = MkQu_DLN D.Current+type Temperature         = MkQu_DLN D.Temperature+type AmountOfSubstance   = MkQu_DLN D.AmountOfSubstance+type LuminousIntensity   = MkQu_DLN D.LuminousIntensity+type PlaneAngle          = MkQu_D D.PlaneAngle+type SolidAngle          = MkQu_D D.SolidAngle -type Area                = MkQu_DLN D.Area                -type Volume              = MkQu_DLN D.Volume              -type Velocity            = MkQu_DLN D.Velocity            -type Acceleration        = MkQu_DLN D.Acceleration        -type Wavenumber          = MkQu_DLN D.Wavenumber          -type Density             = MkQu_DLN D.Density             -type SurfaceDensity      = MkQu_DLN D.SurfaceDensity      -type SpecificVolume      = MkQu_DLN D.SpecificVolume      -type CurrentDensity      = MkQu_DLN D.CurrentDensity      -type MagneticStrength    = MkQu_DLN D.MagneticStrength    -type Concentration       = MkQu_DLN D.Concentration       -type Luminance           = MkQu_DLN D.Luminance           -type Frequency           = MkQu_DLN D.Frequency           -type Force               = MkQu_DLN D.Force               -type Pressure            = MkQu_DLN D.Pressure            -type Energy              = MkQu_DLN D.Energy              -type Power               = MkQu_DLN D.Power               -type Charge              = MkQu_DLN D.Charge              -type ElectricPotential   = MkQu_DLN D.ElectricPotential   -type Capacitance         = MkQu_DLN D.Capacitance         -type Resistance          = MkQu_DLN D.Resistance          -type Conductance         = MkQu_DLN D.Conductance         -type MagneticFlux        = MkQu_DLN D.MagneticFlux        -type MagneticFluxDensity = MkQu_DLN D.MagneticFluxDensity -type Inductance          = MkQu_DLN D.Inductance          -type LuminousFlux        = MkQu_DLN D.LuminousFlux        -type Illuminance         = MkQu_DLN D.Illuminance         -type Kerma               = MkQu_DLN D.Kerma               -type CatalyticActivity   = MkQu_DLN D.CatalyticActivity   -type Momentum            = MkQu_DLN D.Momentum            +type Area                = MkQu_DLN D.Area+type Volume              = MkQu_DLN D.Volume+type Velocity            = MkQu_DLN D.Velocity+type Acceleration        = MkQu_DLN D.Acceleration+type Wavenumber          = MkQu_DLN D.Wavenumber+type Density             = MkQu_DLN D.Density+type SurfaceDensity      = MkQu_DLN D.SurfaceDensity+type SpecificVolume      = MkQu_DLN D.SpecificVolume+type CurrentDensity      = MkQu_DLN D.CurrentDensity+type MagneticStrength    = MkQu_DLN D.MagneticStrength+type Concentration       = MkQu_DLN D.Concentration+type Luminance           = MkQu_DLN D.Luminance+type Frequency           = MkQu_DLN D.Frequency+type Force               = MkQu_DLN D.Force+type Pressure            = MkQu_DLN D.Pressure+type Energy              = MkQu_DLN D.Energy+type Power               = MkQu_DLN D.Power+type Charge              = MkQu_DLN D.Charge+type ElectricPotential   = MkQu_DLN D.ElectricPotential+type Capacitance         = MkQu_DLN D.Capacitance+type Resistance          = MkQu_DLN D.Resistance+type Conductance         = MkQu_DLN D.Conductance+type MagneticFlux        = MkQu_DLN D.MagneticFlux+type MagneticFluxDensity = MkQu_DLN D.MagneticFluxDensity+type Inductance          = MkQu_DLN D.Inductance+type LuminousFlux        = MkQu_DLN D.LuminousFlux+type Illuminance         = MkQu_DLN D.Illuminance+type Kerma               = MkQu_DLN D.Kerma+type CatalyticActivity   = MkQu_DLN D.CatalyticActivity+type Momentum            = MkQu_DLN D.Momentum+type AngularVelocity     = MkQu_DLN D.AngularVelocity
− Data/Metrology/SI/Prefixes.hs
@@ -1,217 +0,0 @@-{-# LANGUAGE TypeOperators #-}---------------------------------------------------------------------------------- |--- Module      :  Data.Metrology.SI.Prefixes--- Copyright   :  (C) 2013 Richard Eisenberg--- License     :  BSD-style (see LICENSE)--- Maintainer  :  Richard Eisenberg (eir@cis.upenn.edu)--- Stability   :  experimental--- Portability :  non-portable------ Defines prefixes from the SI standard at <http://www.bipm.org/en/si/>--------------------------------------------------------------------------------module Data.Metrology.SI.Prefixes where--import Data.Metrology---- | 10^1-data Deca = Deca-instance UnitPrefix Deca where-  multiplier _ = 1e1-instance Show Deca where-  show _ = "da"--deca :: unit -> Deca :@ unit-deca = (Deca :@)---- | 10^2-data Hecto = Hecto-instance UnitPrefix Hecto where-  multiplier _ = 1e2-instance Show Hecto where-  show _ = "h"--hecto :: unit -> Hecto :@ unit-hecto = (Hecto :@)---- | 10^3-data Kilo = Kilo-instance UnitPrefix Kilo where-  multiplier _ = 1e3-instance Show Kilo where-  show _ = "k"--kilo :: unit -> Kilo :@ unit-kilo = (Kilo :@)---- | 10^6-data Mega = Mega-instance UnitPrefix Mega where-  multiplier _ = 1e6-instance Show Mega where-  show _ = "M"--mega :: unit -> Mega :@ unit-mega = (Mega :@)---- | 10^9-data Giga = Giga-instance UnitPrefix Giga where-  multiplier _ = 1e9-instance Show Giga where-  show _ = "G"--giga :: unit -> Giga :@ unit-giga = (Giga :@)---- | 10^12-data Tera = Tera-instance UnitPrefix Tera where-  multiplier _ = 1e12-instance Show Tera where-  show _ = "T"--tera :: unit -> Tera :@ unit-tera = (Tera :@)---- | 10^15-data Peta = Peta-instance UnitPrefix Peta where-  multiplier _ = 1e15-instance Show Peta where-  show _ = "P"--peta :: unit -> Peta :@ unit-peta = (Peta :@)---- | 10^18-data Exa = Exa-instance UnitPrefix Exa where-  multiplier _ = 1e18-instance Show Exa where-  show _ = "E"--exa :: unit -> Exa :@ unit-exa = (Exa :@)---- | 10^21-data Zetta = Zetta-instance UnitPrefix Zetta where-  multiplier _ = 1e21-instance Show Zetta where-  show _ = "Z"--zetta :: unit -> Zetta :@ unit-zetta = (Zetta :@)---- | 10^24-data Yotta = Yotta-instance UnitPrefix Yotta where-  multiplier _ = 1e24-instance Show Yotta where-  show _ = "Y"--yotta :: unit -> Yotta :@ unit-yotta = (Yotta :@)---- | 10^-1-data Deci = Deci-instance UnitPrefix Deci where-  multiplier _ = 1e-1-instance Show Deci where-  show _ = "d"--deci :: unit -> Deci :@ unit-deci = (Deci :@)---- | 10^-2-data Centi = Centi-instance UnitPrefix Centi where-  multiplier _ = 1e-2-instance Show Centi where-  show _ = "c"--centi :: unit -> Centi :@ unit-centi = (Centi :@)---- | 10^-3-data Milli = Milli-instance UnitPrefix Milli where-  multiplier _ = 1e-3-instance Show Milli where-  show _ = "m"--milli :: unit -> Milli :@ unit-milli = (Milli :@)---- | 10^-6-data Micro = Micro-instance UnitPrefix Micro where-  multiplier _ = 1e-6-instance Show Micro where-  show _ = "μ"--micro :: unit -> Micro :@ unit-micro = (Micro :@)---- | 10^-9-data Nano = Nano-instance UnitPrefix Nano where-  multiplier _ = 1e-9-instance Show Nano where-  show _ = "n"--nano :: unit -> Nano :@ unit-nano = (Nano :@)---- | 10^-12-data Pico = Pico-instance UnitPrefix Pico where-  multiplier _ = 1e-12-instance Show Pico where-  show _ = "p"--pico :: unit -> Pico :@ unit-pico = (Pico :@)---- | 10^-15-data Femto = Femto-instance UnitPrefix Femto where-  multiplier _ = 1e-15-instance Show Femto where-  show _ = "f"--femto :: unit -> Femto :@ unit-femto = (Femto :@)---- | 10^-18-data Atto = Atto-instance UnitPrefix Atto where-  multiplier _ = 1e-18-instance Show Atto where-  show _ = "a"--atto :: unit -> Atto :@ unit-atto = (Atto :@)---- | 10^-21-data Zepto = Zepto-instance UnitPrefix Zepto where-  multiplier _ = 1e-21-instance Show Zepto where-  show _ = "z"--zepto :: unit -> Zepto :@ unit-zepto = (Zepto :@)---- | 10^-24-data Yocto = Yocto-instance UnitPrefix Yocto where-  multiplier _ = 1e-24-instance Show Yocto where-  show _ = "y"--yocto :: unit -> Yocto :@ unit-yocto = (Yocto :@)
− Data/Metrology/SI/Units.hs
@@ -1,252 +0,0 @@-{-# LANGUAGE TypeFamilies, TypeOperators, PatternSynonyms #-}---------------------------------------------------------------------------------- |--- Module      :  Data.Metrology.SI.Units--- Copyright   :  (C) 2013 Richard Eisenberg--- License     :  BSD-style (see LICENSE)--- Maintainer  :  Richard Eisenberg (eir@cis.upenn.edu)--- Stability   :  experimental--- Portability :  non-portable------ This module exports unit definitions according to the SI system of units.--- The definitions were taken from here: <http://www.bipm.org/en/si/>.------ Some additional units were added base on--- <http://www.bipm.org/en/si/si_brochure/chapter4/table6.html this link>:--- "Non-SI units accepted for use with the SI,--- and units based on fundamental constants".------ There is one deviation from the definition at that site: To work better--- with prefixes, the unit of mass is 'Gram'.------ This module exports both American spellings and British spellings of--- units, using pattern synonyms to get the British spellings of data--- constructors.--------------------------------------------------------------------------------module Data.Metrology.SI.Units where--import Data.Metrology-import Data.Metrology.SI.Dims-import Data.Metrology.SI.Prefixes ( Kilo, Centi )--data Meter = Meter-instance Unit Meter where-  type BaseUnit Meter = Canonical-  type DimOfUnit Meter = Length-instance Show Meter where-  show _ = "m"--type Metre = Meter-pattern Metre = Meter--data Gram = Gram-instance Unit Gram where-  type BaseUnit Gram = Canonical-  type DimOfUnit Gram = Mass-instance Show Gram where-  show _ = "g"--data Second = Second-instance Unit Second where-  type BaseUnit Second = Canonical-  type DimOfUnit Second = Time-instance Show Second where-  show _ = "s"---- | Derived SI unit-data Minute = Minute-instance Unit Minute where-  type BaseUnit Minute = Second-  conversionRatio _ = 60-instance Show Minute where-  show _ = "min"---- | Derived SI unit-data Hour = Hour-instance Unit Hour where-  type BaseUnit Hour = Minute-  conversionRatio _ = 60-instance Show Hour where-  show _ = "h"--data Day = Day-instance Unit Day where-  type BaseUnit Day = Hour-  conversionRatio _ = 24-instance Show Day where-  show _ = "d"--data Ampere = Ampere-instance Unit Ampere where-  type BaseUnit Ampere = Canonical-  type DimOfUnit Ampere = Current-instance Show Ampere where-  show _ = "A"--data Kelvin = Kelvin-instance Unit Kelvin where-  type BaseUnit Kelvin = Canonical-  type DimOfUnit Kelvin = Temperature-instance Show Kelvin where-  show _ = "K"--data Mole = Mole-instance Unit Mole where-  type BaseUnit Mole = Canonical-  type DimOfUnit Mole = AmountOfSubstance-instance Show Mole where-  show _ = "mol"--data Candela = Candela-instance Unit Candela where-  type BaseUnit Candela = Canonical-  type DimOfUnit Candela = LuminousIntensity-instance Show Candela where-  show _ = "cd"--data Hertz = Hertz-instance Unit Hertz where-  type BaseUnit Hertz = Number :/ Second-instance Show Hertz where-  show _ = "Hz"---- | This is not in the SI standard, but is used widely.-data Liter = Liter-instance Unit Liter where-  type BaseUnit Liter = (Centi :@ Meter) :^ Three-  conversionRatio _ = 1000-instance Show Liter where-  show _ = "l"--type Litre = Liter-pattern Litre = Liter--data Newton = Newton-instance Unit Newton where-  type BaseUnit Newton = Gram :* Meter :/ (Second :^ Two)-  conversionRatio _ = 1000-instance Show Newton where-  show _ = "N"--data Pascal = Pascal-instance Unit Pascal where-  type BaseUnit Pascal = Newton :/ (Meter :^ Two)-instance Show Pascal where-  show _ = "Pa"--data Joule = Joule-instance Unit Joule where-  type BaseUnit Joule = Newton :* Meter-instance Show Joule where-  show _ = "J"--data Watt = Watt-instance Unit Watt where-  type BaseUnit Watt = Joule :/ Second-instance Show Watt where-  show _ = "W"--data Coulomb = Coulomb-instance Unit Coulomb where-  type BaseUnit Coulomb = Ampere :* Second-instance Show Coulomb where-  show _ = "C"--data Volt = Volt-instance Unit Volt where-  type BaseUnit Volt = Watt :/ Ampere-instance Show Volt where-  show _ = "V"--data Farad = Farad-instance Unit Farad where-  type BaseUnit Farad = Coulomb :/ Volt-instance Show Farad where-  show _ = "F"--data Ohm = Ohm-instance Unit Ohm where-  type BaseUnit Ohm = Volt :/ Ampere-instance Show Ohm where-  show _ = "Ω"--data Siemens = Siemens-instance Unit Siemens where-  type BaseUnit Siemens = Ampere :/ Volt-instance Show Siemens where-  show _ = "S"--data Weber = Weber-instance Unit Weber where-  type BaseUnit Weber = Volt :* Second-instance Show Weber where-  show _ = "Wb"--data Tesla = Tesla-instance Unit Tesla where-  type BaseUnit Tesla = Weber :/ (Meter :^ Two)-instance Show Tesla where-  show _ = "T"--data Henry = Henry-instance Unit Henry where-  type BaseUnit Henry = Weber :/ Ampere-instance Show Henry where-  show _ = "H"--data Lumen = Lumen-instance Unit Lumen where-  type BaseUnit Lumen = Candela-instance Show Lumen where-  show _ = "lm"--data Lux = Lux-instance Unit Lux where-  type BaseUnit Lux = Lumen :/ (Meter :^ Two)-instance Show Lux where-  show _ = "lx"--data Becquerel = Becquerel-instance Unit Becquerel where-  type BaseUnit Becquerel = Number :/ Second-instance Show Becquerel where-  show _ = "Bq"--data Gray = Gray-instance Unit Gray where-  type BaseUnit Gray = (Meter :^ Two) :/ (Second :^ Two)-instance Show Gray where-  show _ = "Gy"--data Sievert = Sievert-instance Unit Sievert where-  type BaseUnit Sievert = (Meter :^ Two) :/ (Second :^ Two)-instance Show Sievert where-  show _ = "Sv"--data Katal = Katal-instance Unit Katal where-  type BaseUnit Katal = Mole :/ Second-instance Show Katal where-  show _ = "kat"---- | Derived SI unit-data Hectare = Hectare-instance Unit Hectare where-  type BaseUnit Hectare = Meter :^ Two-  conversionRatio _ = 10000-instance Show Hectare where-  show _ = "ha"---- | Derived SI unit-data Ton = Ton-instance Unit Ton where-  type BaseUnit Ton = Kilo :@ Gram-  conversionRatio _ = 1000-instance Show Ton where-  show _ = "t"--type Tonne = Ton-pattern Tonne = Ton
+ Data/Units/Astronomical.hs view
@@ -0,0 +1,49 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.Astronomical+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- The system of astronomical units, as defined by the International+-- Astronomical Union in 1976 and since then updated a few times.+--+-- The IAU documents used as reference are as follows:+-- <http://www.iau.org/static/resolutions/IAU1976_French.pdf>+-- <http://www.iau.org/static/resolutions/IAU1994_French.pdf>+-- <http://syrte.obspm.fr/IAU_resolutions/Res_IAU2012_B2.pdf>+-- <https://www.iau.org/publications/proceedings_rules/units/>+-----------------------------------------------------------------------------++module Data.Units.Astronomical (+  -- * Lengths+  AstronomicalUnit(..), LightYear(..), Parsec(..),++  -- * Time+  Day(..), JulianYear(..), JulianCentury(..),++  -- * Mass+  SolarMass(..), JovianMass(..), EarthMass(..)+  ) where++import Data.Constants.Math+import Data.Metrology.TH+import Data.Metrology+import Data.Units.SI+import Data.Units.SI.Prefixes++declareDerivedUnit "Day"           [t| Second |]        86400 (Just "D")+declareDerivedUnit "JulianCentury" [t| Day |]           36525 (Just "julian century")+declareDerivedUnit "JulianYear"    [t| JulianCentury |] 0.01  (Just "a")++declareDerivedUnit "AstronomicalUnit" [t| Metre            |] 149597870700     (Just "au")+declareDerivedUnit "LightYear"        [t| Metre            |] 9460730472580800 (Just "ly")+declareDerivedUnit "Parsec"           [t| AstronomicalUnit |] (648000 / piR)   (Just "pc")++declareDerivedUnit "SolarMass"  [t| Kilo :@ Gram |] (1.9891 * 10 ^ (30 :: Int)) (Just "S")+declareDerivedUnit "EarthMass"  [t| SolarMass |]    (1 / 332946.0487)           (Just "E")+declareDerivedUnit "JovianMass" [t| SolarMass |]    (1 / 1047.348644)           (Just "MJ")
+ Data/Units/CGS.hs view
@@ -0,0 +1,64 @@+{-# LANGUAGE PatternSynonyms, TemplateHaskell, TypeOperators,+             TypeFamilies, CPP #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.CGS+-- Copyright   :  (C) 2014 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- This module defines units used in the centimeter\/gram\/second system+-- of measurement.+--+-- Included are all mechanical units mentioned here:+-- <http://en.wikipedia.org/wiki/Centimetre%E2%80%93gram%E2%80%93second_system_of_units>+--+-- Some electromagnetic units are not included, because these do not have+-- reliable conversions to\/from the SI units, on which the @units-defs@+-- edifice is based.+-----------------------------------------------------------------------------++module Data.Units.CGS (+  Centi(..), centi, Meter(..), pattern Metre, Gram(..), Second(..),+  module Data.Units.CGS+  ) where++import Data.Units.SI+import Data.Units.SI.Prefixes+import Data.Metrology.Poly+import Data.Metrology.TH++type Centimeter = Centi :@ Meter++#if __GLASGOW_HASKELL__ >= 710+pattern Centimeter :: Centimeter+#endif+pattern Centimeter = Centi :@ Meter++type Centimetre = Centimeter++#if __GLASGOW_HASKELL__ >= 710+pattern Centimetre :: Centimetre+#endif+pattern Centimetre = Centimeter++declareDerivedUnit "Gal"+  [t| Centimeter :/ Second :^ Two |]                1 (Just "Gal")+declareDerivedUnit "Dyne"+  [t| Gram :* Centimeter :/ Second :^ Two |]        1 (Just "dyn")+declareDerivedUnit "Erg"+  [t| Gram :* Centimeter :^ Two :/ Second :^ Two |] 1 (Just "erg")+declareDerivedUnit "Barye"+  [t| Gram :/ (Centimeter :* Second :^ Two) |]      1 (Just "Ba")+declareDerivedUnit "Poise"+  [t| Gram :/ (Centimeter :* Second) |]             1 (Just "P")+declareDerivedUnit "Stokes"+  [t| Centimeter :^ Two :/ Second |]                1 (Just "St")+declareDerivedUnit "Kayser"+  [t| Centimeter :^ MOne |]                         1 Nothing++declareDerivedUnit "Maxwell" [t| Nano :@ Weber |]  10  (Just "Mx")+declareDerivedUnit "Gauss"   [t| Milli :@ Tesla |] 0.1 (Just "G")
+ Data/Units/Eurocard.hs view
@@ -0,0 +1,26 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.Eurocard+-- Copyright   :  (C) 2018 Mario Lang+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- The units of length as defined by the eurocard standard.+--+-- See <https://en.wikipedia.org/wiki/Eurocard_(printed_circuit_board)> or IEC 60297.+-----------------------------------------------------------------------------++module Data.Units.Eurocard (+  -- * Lengths+  RackUnit(..), HorizontalPitch(..)+  ) where++import Data.Metrology.TH+import Data.Units.US (Inch)++declareDerivedUnit "HorizontalPitch" [t| Inch |] 0.2  (Just "HP")+declareDerivedUnit "RackUnit"        [t| Inch |] 1.75 (Just "U")
+ Data/Units/Imperial.hs view
@@ -0,0 +1,68 @@+-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.Imperial+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- This module defines the Imperial system of units, based on the+-- Exchequer Standards of 1825. Two big differences between the+-- Imperial system and the US customary one are that because the+-- USA declared their independence from the UK in 1776, the US+-- customary system is based on the previous Winchester Standards, and+-- that the Imperial system uses the same units for dry and fluid+-- measures. This module gathers together a subjective set of units of+-- general use appearing <https://en.wikipedia.org/wiki/Imperial_units+-- here>, submodules will gather measures of more limited use. It also+-- exports type instances 'DefaultUnitOfDim' that use the /SI/ internal+-- representations. This choice is made for inter-compatibility with SI+-- computations. If you want the foot-pound-second system, use the 'FPS'.+--+-- Where possible, reference have been made to UK legislation. However,+-- Wikipedia's page is /much/ better organized than any government+-- resource immediately available.+--+-- The UK legislation used as references are as follows:+-- <http://www.legislation.gov.uk/ukpga/1985/72/enacted>+-- <http://www.legislation.gov.uk/uksi/1994/2867/schedule/part/VI/made>+-- <http://www.legislation.gov.uk/uksi/1995/1804/schedule/made>+-----------------------------------------------------------------------------++module Data.Units.Imperial (+  -- * Lengths+  Thou(..), Inch(..), Foot(..), Yard(..), Mile(..), NauticalMile(..),++  -- * Velocity+  Knot(..),++  -- * Area+  Acre(..),++  -- * Volume+  FluidOunce(..), Pint(..), Quart(..), Gallon(..),++  -- * Mass+  -- | These are all in the avoirdupois system+  Ounce(..), Pound(..), Stone(..), Ton(..),++  -- * Pressure+  InchOfWater(..),++  -- * Energy+  FootPoundForce(..), Therm(..), BritishThermalUnit(..),++  -- * Power+  Horsepower(..),++  -- * Temperature+  Fahrenheit(..)+  ) where++import Data.Units.Imperial.Misc+import Data.Units.Imperial.Nautical+import Data.Units.Imperial.Weight+import Data.Units.Imperial.Volume+import Data.Units.Imperial.Area+import Data.Units.Imperial.Length
+ Data/Units/Imperial/Area.hs view
@@ -0,0 +1,41 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.Imperial.Area+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- The traditional area units are defined in reference to the survey+-- ones.+--+-- Where possible, reference have been made to UK legislation. However,+-- Wikipedia's page is /much/ better organized than any government+-- resource immediately available.+--+-- The UK legislation used as references are as follows:+-- <http://www.legislation.gov.uk/ukpga/1985/72/enacted>+-- <http://www.legislation.gov.uk/uksi/1994/2867/schedule/part/VI/made>+-- <http://www.legislation.gov.uk/uksi/1995/1804/schedule/made>+-----------------------------------------------------------------------------++module Data.Units.Imperial.Area where++import Data.Metrology+import Data.Metrology.TH++import Data.Units.Imperial.Length+import Data.Units.Imperial.Survey++import Language.Haskell.TH++declareDerivedUnit "Perch" [t| Rod :* Rod       |] 1 (Just "perch")+declareDerivedUnit "Rood"  [t| Furlong :* Rod   |] 1 (Just "rood")+declareDerivedUnit "Acre"  [t| Furlong :* Chain |] 1 (Just "acre")++-- | Areas units: All units above+areas :: [Name]+areas = [ ''Perch, ''Rood, ''Acre ]
+ Data/Units/Imperial/Length.hs view
@@ -0,0 +1,55 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.Imperial.Length+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- Due to the <https://en.wikipedia.org/wiki/International_yard_and_pound+-- International yard and pound agreement of 1959>, it so happens that+-- Imperial and US customary units of length have the same base (the+-- international yard at 0.9144 meters). However, if subdivisions are+-- generally the same, Imperial units feature multiples of the yard that+-- US customary ones generally don't (e.g. the Imperial furlong is defined+-- by reference to the international yard, not the US survey one).+--+-- Where possible, reference have been made to UK legislation. However,+-- Wikipedia's page is /much/ better organized than any government+-- resource immediately available.+--+-- The UK legislation used as references are as follows:+-- <http://www.legislation.gov.uk/ukpga/1985/72/enacted>+-- <http://www.legislation.gov.uk/uksi/1994/2867/schedule/part/VI/made>+-- <http://www.legislation.gov.uk/uksi/1995/1804/schedule/made>+-----------------------------------------------------------------------------++module Data.Units.Imperial.Length where++import Data.Metrology.TH++import qualified Data.Units.US.Misc as US++import Language.Haskell.TH++declareDerivedUnit "Thou"    [t| US.Mil  |] 1  (Just "th")+declareDerivedUnit "Inch"    [t| US.Inch |] 1  (Just "in")+declareDerivedUnit "Foot"    [t| US.Foot |] 1  (Just "ft")+declareDerivedUnit "Yard"    [t| US.Yard |] 1  (Just "yd")+declareDerivedUnit "Chain"   [t| Yard    |] 22 (Just "ch")+declareDerivedUnit "Furlong" [t| Chain   |] 10 (Just "fur")+declareDerivedUnit "Mile"    [t| US.Mile |] 1  (Just "mi")+declareDerivedUnit "League"  [t| Mile    |] 3  (Just "lea")++declareDerivedUnit "Hand" [t| Inch |] 4 (Just "hand")++-- | Common lengths units: 'Foot', 'Inch', 'Yard', and 'Mile'+commonLengths :: [Name]+commonLengths = [ ''Foot, ''Inch, ''Yard, ''Mile ]++-- | Other lengths units: 'Thou', 'Hand', 'Chain', 'Furlong' and 'League'+otherLengths :: [Name]+otherLengths = [ ''Thou, ''Hand, ''Chain, ''Furlong, ''League ]
+ Data/Units/Imperial/Misc.hs view
@@ -0,0 +1,73 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.Imperial.Misc+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- Miscellaneous units not easily put in another module.+--+-- Where possible, reference have been made to UK legislation. However,+-- Wikipedia's page is /much/ better organized than any government+-- resource immediately available.+--+-- The UK legislation used as references are as follows:+-- <http://www.legislation.gov.uk/ukpga/1985/72/enacted>+-- <http://www.legislation.gov.uk/uksi/1994/2867/schedule/part/VI/made>+-- <http://www.legislation.gov.uk/uksi/1995/1804/schedule/made>+-----------------------------------------------------------------------------++module Data.Units.Imperial.Misc where++import Data.Metrology+import Data.Metrology.TH++import Data.Units.SI+import Data.Units.Imperial.Nautical++import Language.Haskell.TH++declareDerivedUnit "Knot" [t| NauticalMile :/ Hour |] 1 (Just "kn")++declareDerivedUnit "InchOfWater" [t| Pascal |] 249.08891 (Just "inAq")++declareDerivedUnit "PoundForce" [t| Newton     |] 4.4482216152605  (Just "lbf")+declareDerivedUnit "TonForce"   [t| PoundForce |] 2240             (Just "tf")++declareDerivedUnit "Horsepower" [t| Watt |] 745.69987158227022 (Just "hp")++declareDerivedUnit "FootPoundForce"     [t| Joule |]              1.3558179483314004 (Just "ft⋅lbf")+declareDerivedUnit "BritishThermalUnit" [t| Joule |]              1055.05585257348   (Just "Btu")+declareDerivedUnit "Therm"              [t| BritishThermalUnit |] 100000             (Just "thm")++declareDerivedUnit "FootCandle" [t| Lux |] 10.763910416709 (Just "fc")++declareDerivedUnit "Fahrenheit" [t| Kelvin |] (5/9)  (Just "°F")++-- | Speed units: 'Knot'+speeds :: [Name]+speeds = [ ''Knot ]++-- | Temperature units: 'Fahrenheit'+temperatures :: [Name]+temperatures = [ ''Fahrenheit ]++-- | Illuminance units: 'FootCandle'+illuminances :: [Name]+illuminances = [ ''FootCandle ]++-- | Force units: 'PoundForce' and 'TonForce'+forces :: [Name]+forces = [ ''PoundForce, ''TonForce ]++-- | Energy units: 'FootPoundForce', 'BritishThermalUnit' and 'Therm'+energies :: [Name]+energies = [ ''FootPoundForce, ''BritishThermalUnit, ''Therm ]++-- | Power units: 'Horsepower'+powers :: [Name]+powers = [ ''Horsepower ]
+ Data/Units/Imperial/Nautical.hs view
@@ -0,0 +1,39 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.Imperial.Nautical+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- As per current UK legislation, the nautical mile is defined as 1853 m,+-- not 1852 (as it was previously).+--+-- Where possible, reference have been made to UK legislation. However,+-- Wikipedia's page is /much/ better organized than any government+-- resource immediately available.+--+-- The UK legislation used as references are as follows:+-- <http://www.legislation.gov.uk/ukpga/1985/72/enacted>+-- <http://www.legislation.gov.uk/uksi/1994/2867/schedule/part/VI/made>+-- <http://www.legislation.gov.uk/uksi/1995/1804/schedule/made>+-----------------------------------------------------------------------------++module Data.Units.Imperial.Nautical where++import Data.Metrology.TH++import Data.Units.SI++import Language.Haskell.TH++declareDerivedUnit "NauticalMile" [t| Metre        |] 1853 (Just "NM")+declareDerivedUnit "Cable"        [t| NauticalMile |] 0.1  (Just "cable")+declareDerivedUnit "Fathom"       [t| Cable        |] 0.01 (Just "ftm")++-- | Nautical lengths: All units above+nauticalLengths :: [Name]+nauticalLengths = [ ''Fathom, ''Cable, ''NauticalMile ]
+ Data/Units/Imperial/Survey.hs view
@@ -0,0 +1,34 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.Imperial.Survey+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- Survey units are Gunter's units, so called because thay have been+-- standardised by Edmund Gunter in 1620 at 25 links to the rod, 4 rods+-- to the chain.+--+-- Where possible, reference have been made to UK legislation. However,+-- Wikipedia's page is /much/ better organized than any government+-- resource immediately available.+-----------------------------------------------------------------------------++module Data.Units.Imperial.Survey where++import Data.Metrology.TH++import Data.Units.Imperial.Length++import Language.Haskell.TH++declareDerivedUnit "Rod"  [t| Chain |] 0.25 (Just "rd")+declareDerivedUnit "Link" [t| Rod   |] 0.04 (Just "li")++-- | Survey lengths: All units above+surveyLengths :: [Name]+surveyLengths = [ ''Link, ''Rod ]
+ Data/Units/Imperial/Volume.hs view
@@ -0,0 +1,47 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.Imperial.Volume+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- There's only one set of volume units in the Imperial system, hence the+-- one ´Volume´ module to the two (´Liquid´ and ´DryVolume´) in the US system.+--+-- Where possible, reference have been made to UK legislation. However,+-- Wikipedia's page is /much/ better organized than any government+-- resource immediately available.+--+-- The UK legislation used as references are as follows:+-- <http://www.legislation.gov.uk/ukpga/1985/72/enacted>+-- <http://www.legislation.gov.uk/uksi/1994/2867/schedule/part/VI/made>+-- <http://www.legislation.gov.uk/uksi/1995/1804/schedule/made>+-----------------------------------------------------------------------------++module Data.Units.Imperial.Volume where++import Data.Metrology.TH+import Data.Units.SI++import Language.Haskell.TH++declareDerivedUnit "Gallon"     [t| Litre  |] 4.54609 (Just "gal")+declareDerivedUnit "Quart"      [t| Gallon |] 0.25    (Just "qt")+declareDerivedUnit "Pint"       [t| Quart  |] 0.5     (Just "pt")+declareDerivedUnit "Gill"       [t| Pint   |] 0.25    (Just "gi")+declareDerivedUnit "FluidOunce" [t| Gill   |] 0.2     (Just "fl oz")++declareDerivedUnit "Cran"   [t| Gallon |] 37.5 (Just "cran")+declareDerivedUnit "Bushel" [t| Gallon |] 8    (Just "bsh")++-- | Includes 'FluidOunce', 'Pint', 'Gallon'+commonVolumeMeasures :: [Name]+commonVolumeMeasures = [ ''FluidOunce, ''Pint, ''Gallon ]++-- | Includes 'Gill', 'Quart', 'Cran' and 'Bushel'+otherVolumeMeasures :: [Name]+otherVolumeMeasures = [ ''Gill, ''Quart, ''Bushel, ''Cran ]
+ Data/Units/Imperial/Weight.hs view
@@ -0,0 +1,59 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.Imperial.Weight+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- Due to the <https://en.wikipedia.org/wiki/International_yard_and_pound+-- International yard and pound agreement of 1959>, it so happens that+-- Imperial and US customary units of weight have the same base (the+-- international pound at 0.45359237 kilograms). However, if subdivisions+-- are generally the same, Imperial units feature different multiples of+-- the pound, due to the presence of the stone. As in, using English+-- conventions, the hundredweight is the *long* one (the short one is the+-- cental). As is the ton.+-- Also, of the troy system (the international one being, more or less,+-- the avoirdupoids one) only the ounce is legal.+--+-- Where possible, reference have been made to UK legislation. However,+-- Wikipedia's page is /much/ better organized than any government+-- resource immediately available.+--+-- The UK legislation used as references are as follows:+-- <http://www.legislation.gov.uk/ukpga/1985/72/enacted>+-- <http://www.legislation.gov.uk/uksi/1994/2867/schedule/part/VI/made>+-- <http://www.legislation.gov.uk/uksi/1995/1804/schedule/made>+-----------------------------------------------------------------------------++module Data.Units.Imperial.Weight where++import Data.Metrology.TH++import qualified Data.Units.SI as SI+import qualified Data.Units.US.Avoirdupois as Avdp++import Language.Haskell.TH++declareDerivedUnit "Pound"         [t| Avdp.Pound    |] 1          (Just "lb")+declareDerivedUnit "Grain"         [t| Avdp.Grain    |] 1          (Just "gr")+declareDerivedUnit "Dram"          [t| Avdp.Dram     |] 1          (Just "dr")+declareDerivedUnit "Ounce"         [t| Avdp.Ounce    |] 1          (Just "oz")+declareDerivedUnit "TroyOunce"     [t| SI.Gramme     |] 31.1034768 (Just "t oz")+declareDerivedUnit "Stone"         [t| Pound         |] 14         (Just "st")+declareDerivedUnit "Quarter"       [t| Stone         |] 2          (Just "qr")+declareDerivedUnit "Cental"        [t| Pound         |] 100        (Just "cental")+declareDerivedUnit "Hundredweight" [t| Quarter       |] 4          (Just "cwt")+declareDerivedUnit "Ton"           [t| Hundredweight |] 20         (Just "t")++-- | Includes 'Ounce', 'Pound', 'Ton'+commonMassMeasures :: [Name]+commonMassMeasures = [ ''Ounce, ''Pound, ''Ton ]++-- | Includes 'Grain', 'Dram', 'TroyOunce', 'Stone', 'Quarter', 'Cental' and 'Hundredweight'+otherMassMeasures :: [Name]+otherMassMeasures = [ ''Grain, ''Dram, ''TroyOunce, ''Stone, ''Quarter, ''Cental, ''Hundredweight ]
+ Data/Units/PreciousMetals.hs view
@@ -0,0 +1,28 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Metrology.Units.PreciousMetals+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- Units used in the measure of precious metals.+-----------------------------------------------------------------------------++module Data.Units.PreciousMetals where++import Data.Metrology+import Data.Metrology.TH+import Data.Units.SI+import Data.Units.SI.Prefixes++import qualified Data.Units.US.Avoirdupois as Avdp+import qualified Data.Units.US.Troy        as Troy++declareDerivedUnit "Carat"    [t| Milli :@ Gram |] 200  (Just "carat")+declareDerivedUnit "Point"    [t| Carat         |] 0.01 (Just "point")+declareDerivedUnit "AssayTon" [t| (Milli :@ Gram) :* (Avdp.Ton :/ Troy.Ounce) |]+                              1 (Just "AT")
+ Data/Units/SI.hs view
@@ -0,0 +1,134 @@+{-# LANGUAGE TypeFamilies, TypeOperators, PatternSynonyms, TemplateHaskell, CPP #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.SI+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- This module exports unit definitions according to the SI system of units.+-- The definitions were taken from here: <http://www.bipm.org/en/si/>.+--+-- Some additional units were added based on+-- <http://www.bipm.org/en/si/si_brochure/chapter4/table6.html this link>:+-- "Non-SI units accepted for use with the SI,+-- and units based on fundamental constants".+--+-- There is one deviation from the definitions at that site: To work better+-- with prefixes, the unit of mass is 'Gram'.+--+-- This module exports both American spellings and British spellings of+-- units, using pattern synonyms to get the British spellings of data+-- constructors.+-----------------------------------------------------------------------------++module Data.Units.SI where++import Data.Metrology.Poly+import Data.Metrology.TH+import Data.Dimensions.SI+import Data.Units.SI.Prefixes ( Kilo, Centi )+import Data.Constants.Math (piR)++import Language.Haskell.TH ( Name )++declareCanonicalUnit "Meter"   [t| Length |]                         (Just "m")++type Metre = Meter++#if __GLASGOW_HASKELL >= 710+pattern Metre :: Metre+#endif+pattern Metre = Meter++declareCanonicalUnit "Gram"    [t| Mass |]                           (Just "g")++type Gramme = Gram++#if __GLASGOW_HASKELL__ >= 710+pattern Gramme :: Gramme+#endif+pattern Gramme = Gram++declareCanonicalUnit "Second"  [t| Time |]                           (Just "s")++-- | Derived SI unit+declareDerivedUnit "Minute"    [t| Second |]                    60   (Just "min")++-- | Derived SI unit+declareDerivedUnit "Hour"      [t| Minute |]                    60   (Just "h")++declareCanonicalUnit "Ampere"  [t| Current |]                        (Just "A")+declareCanonicalUnit "Kelvin"  [t| Temperature |]                    (Just "K")+declareCanonicalUnit "Mole"    [t| AmountOfSubstance |]              (Just "mol")+declareCanonicalUnit "Candela" [t| LuminousIntensity |]              (Just "cd")++-- | The two angular dimensions that must be fundamental dimensions.+declareCanonicalUnit "Radian"     [t| PlaneAngle |]                  (Just "rad")+declareCanonicalUnit "Steradian"  [t| SolidAngle |]                  (Just "sr")++declareDerivedUnit "Hertz"     [t| Number :/ Second |]          1    (Just "Hz")++-- | This is not in the SI standard, but is used widely.+declareDerivedUnit "Liter"     [t| (Centi :@ Meter) :^ Three |] 1000 (Just "L")++type Litre = Liter++#if __GLASGOW_HASKELL__ >= 710+pattern Litre :: Litre+#endif+pattern Litre = Liter++declareDerivedUnit "Newton"    [t| Gram :* Meter :/ (Second :^ Two) |]  1000  (Just "N")+declareDerivedUnit "Pascal"    [t| Newton :/ (Meter :^ Two) |]          1     (Just "Pa")+declareDerivedUnit "Joule"     [t| Newton :* Meter |]                   1     (Just "J")+declareDerivedUnit "Watt"      [t| Joule :/ Second |]                   1     (Just "W")+declareDerivedUnit "Coulomb"   [t| Ampere :* Second |]                  1     (Just "C")+declareDerivedUnit "Volt"      [t| Watt :/ Ampere |]                    1     (Just "V")+declareDerivedUnit "Farad"     [t| Coulomb :/ Volt |]                   1     (Just "F")+declareDerivedUnit "Ohm"       [t| Volt :/ Ampere |]                    1     (Just "Ω")+declareDerivedUnit "Siemens"   [t| Ampere :/ Volt |]                    1     (Just "S")+declareDerivedUnit "Weber"     [t| Volt :* Second |]                    1     (Just "Wb")+declareDerivedUnit "Tesla"     [t| Weber :/ (Meter :^ Two) |]           1     (Just "T")+declareDerivedUnit "Henry"     [t| Weber :/ Ampere |]                   1     (Just "H")+declareDerivedUnit "Lumen"     [t| Candela |]                           1     (Just "lm")+declareDerivedUnit "Lux"       [t| Lumen :/ (Meter :^ Two) |]           1     (Just "lx")+declareDerivedUnit "Becquerel" [t| Number :/ Second |]                  1     (Just "Bq")+declareDerivedUnit "Gray"      [t| (Meter :^ Two) :/ (Second :^ Two) |] 1     (Just "Gy")+declareDerivedUnit "Sievert"   [t| (Meter :^ Two) :/ (Second :^ Two) |] 1     (Just "Sv")+declareDerivedUnit "Katal"     [t| Mole :/ Second |]                    1     (Just "kat")++-- Non-SI units accepted for use with SI+-- (https://en.wikipedia.org/wiki/International_System_of_Units#Non-SI_units_accepted_for_use_with_SI)+declareDerivedUnit "Degree"       [t| Radian |]       (piR / 180)           (Just "deg")+-- This should be printed as /'/ but Text.Parse.Units.mkSymbolTable says that's illegal.+declareDerivedUnit "Arcminute"    [t| Degree |]       (1 / 60)              (Just "arcminute")+-- This should be printed as /"/ but Text.Parse.Units.mkSymbolTable says that's illegal.+declareDerivedUnit "Arcsecond"    [t| Arcminute |]    (1 / 60)              (Just "arcsecond")++-- | Derived SI unit+declareDerivedUnit "Hectare"   [t| Meter :^ Two |]                      10000 (Just "ha")++-- | Derived SI unit+declareDerivedUnit "Ton"       [t| Kilo :@ Gram |]                      1000  (Just "t")++type Tonne = Ton+#if __GLASGOW_HASKELL__ >= 710+pattern Tonne :: Tonne+#endif+pattern Tonne = Ton++-- | A list of the names of all unit types. Useful with+-- 'Data.Metrology.Parser.makeQuasiQuoter'.+siUnits :: [Name]+siUnits =+  [ ''Meter, ''Gram, ''Second, ''Minute, ''Hour, ''Ampere+  , ''Kelvin, ''Mole, ''Candela, ''Hertz, ''Liter, ''Newton, ''Pascal+  , ''Joule, ''Watt, ''Coulomb, ''Volt, ''Farad, ''Ohm, ''Siemens+  , ''Weber, ''Tesla, ''Henry, ''Lumen, ''Radian, ''Lux, ''Becquerel, ''Gray+  , ''Sievert, ''Katal, ''Degree, ''Arcminute+  , ''Arcsecond,''Hectare, ''Ton+  ]
+ Data/Units/SI/Parser.hs view
@@ -0,0 +1,29 @@+{-# LANGUAGE TemplateHaskell #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.SI.Parser+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- Defines a quasi-quoting parser for unit expressions. Writing, say,+-- @[si| m/s^2 |]@ produces @(Meter :/ (Second :^ sTwo))@. A larger+-- example is+--+-- > ke :: Energy+-- > ke = 5 % [si| N km |]  -- 5 Newton-kilometers+--+-- See `Data.Metrology.Parser` for more information about the syntax+-- of these unit expressions.+-----------------------------------------------------------------------------++module Data.Units.SI.Parser ( si ) where++import Data.Metrology.Parser+import Data.Units.SI.Prefixes+import Data.Units.SI++makeQuasiQuoter "si" siPrefixes siUnits
+ Data/Units/SI/Prefixes.hs view
@@ -0,0 +1,227 @@+{-# LANGUAGE TypeOperators, TemplateHaskell #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.SI.Prefixes+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- Defines prefixes from the SI standard at <http://www.bipm.org/en/si/>+-----------------------------------------------------------------------------++module Data.Units.SI.Prefixes where++import Language.Haskell.TH ( Name )+import Data.Metrology.Poly++-- | 10^1+data Deca = Deca+instance UnitPrefix Deca where+  multiplier _ = 1e1+instance Show Deca where+  show _ = "da"++deca :: unit -> Deca :@ unit+deca = (Deca :@)++-- | 10^2+data Hecto = Hecto+instance UnitPrefix Hecto where+  multiplier _ = 1e2+instance Show Hecto where+  show _ = "h"++hecto :: unit -> Hecto :@ unit+hecto = (Hecto :@)++-- | 10^3+data Kilo = Kilo+instance UnitPrefix Kilo where+  multiplier _ = 1e3+instance Show Kilo where+  show _ = "k"++kilo :: unit -> Kilo :@ unit+kilo = (Kilo :@)++-- | 10^6+data Mega = Mega+instance UnitPrefix Mega where+  multiplier _ = 1e6+instance Show Mega where+  show _ = "M"++mega :: unit -> Mega :@ unit+mega = (Mega :@)++-- | 10^9+data Giga = Giga+instance UnitPrefix Giga where+  multiplier _ = 1e9+instance Show Giga where+  show _ = "G"++giga :: unit -> Giga :@ unit+giga = (Giga :@)++-- | 10^12+data Tera = Tera+instance UnitPrefix Tera where+  multiplier _ = 1e12+instance Show Tera where+  show _ = "T"++tera :: unit -> Tera :@ unit+tera = (Tera :@)++-- | 10^15+data Peta = Peta+instance UnitPrefix Peta where+  multiplier _ = 1e15+instance Show Peta where+  show _ = "P"++peta :: unit -> Peta :@ unit+peta = (Peta :@)++-- | 10^18+data Exa = Exa+instance UnitPrefix Exa where+  multiplier _ = 1e18+instance Show Exa where+  show _ = "E"++exa :: unit -> Exa :@ unit+exa = (Exa :@)++-- | 10^21+data Zetta = Zetta+instance UnitPrefix Zetta where+  multiplier _ = 1e21+instance Show Zetta where+  show _ = "Z"++zetta :: unit -> Zetta :@ unit+zetta = (Zetta :@)++-- | 10^24+data Yotta = Yotta+instance UnitPrefix Yotta where+  multiplier _ = 1e24+instance Show Yotta where+  show _ = "Y"++yotta :: unit -> Yotta :@ unit+yotta = (Yotta :@)++-- | 10^-1+data Deci = Deci+instance UnitPrefix Deci where+  multiplier _ = 1e-1+instance Show Deci where+  show _ = "d"++deci :: unit -> Deci :@ unit+deci = (Deci :@)++-- | 10^-2+data Centi = Centi+instance UnitPrefix Centi where+  multiplier _ = 1e-2+instance Show Centi where+  show _ = "c"++centi :: unit -> Centi :@ unit+centi = (Centi :@)++-- | 10^-3+data Milli = Milli+instance UnitPrefix Milli where+  multiplier _ = 1e-3+instance Show Milli where+  show _ = "m"++milli :: unit -> Milli :@ unit+milli = (Milli :@)++-- | 10^-6+data Micro = Micro+instance UnitPrefix Micro where+  multiplier _ = 1e-6+instance Show Micro where+  show _ = "μ"++micro :: unit -> Micro :@ unit+micro = (Micro :@)++-- | 10^-9+data Nano = Nano+instance UnitPrefix Nano where+  multiplier _ = 1e-9+instance Show Nano where+  show _ = "n"++nano :: unit -> Nano :@ unit+nano = (Nano :@)++-- | 10^-12+data Pico = Pico+instance UnitPrefix Pico where+  multiplier _ = 1e-12+instance Show Pico where+  show _ = "p"++pico :: unit -> Pico :@ unit+pico = (Pico :@)++-- | 10^-15+data Femto = Femto+instance UnitPrefix Femto where+  multiplier _ = 1e-15+instance Show Femto where+  show _ = "f"++femto :: unit -> Femto :@ unit+femto = (Femto :@)++-- | 10^-18+data Atto = Atto+instance UnitPrefix Atto where+  multiplier _ = 1e-18+instance Show Atto where+  show _ = "a"++atto :: unit -> Atto :@ unit+atto = (Atto :@)++-- | 10^-21+data Zepto = Zepto+instance UnitPrefix Zepto where+  multiplier _ = 1e-21+instance Show Zepto where+  show _ = "z"++zepto :: unit -> Zepto :@ unit+zepto = (Zepto :@)++-- | 10^-24+data Yocto = Yocto+instance UnitPrefix Yocto where+  multiplier _ = 1e-24+instance Show Yocto where+  show _ = "y"++yocto :: unit -> Yocto :@ unit+yocto = (Yocto :@)++-- | A list of the names of all prefix types. Useful with+-- 'Data.Metrology.Parser.makeQuasiQuoter'.+siPrefixes :: [Name]+siPrefixes =+  [ ''Deca, ''Hecto, ''Kilo, ''Mega, ''Giga, ''Tera, ''Peta, ''Exa+  , ''Zetta, ''Yotta, ''Deci, ''Centi, ''Milli, ''Micro, ''Nano+  , ''Pico, ''Femto, ''Atto, ''Zepto, ''Yocto+  ]
+ Data/Units/US.hs view
@@ -0,0 +1,62 @@+-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.US+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- This module defines the American customary system of units. Because+-- there are some names that are conflicted, even within this system,+-- there are several modules underneath here, defining sub-parts of+-- the US system. This module gathers together a subjective set of+-- units users will commonly wish to use. It also exports type instances+-- 'DefaultUnitOfDim' that use the /SI/ internal representations. This+-- choice is made for inter-compatibility with SI computations. If you+-- want the foot-pound-second system, use the 'FPS'.+--+-- Included are all units mentioned here:+-- <http://en.wikipedia.org/wiki/United_States_customary_units>+-- Where possible, conversion rates have been independently verified+-- at a US government website. However, Wikipedia's base is /much/+-- better organized than any government resource immediately available.+-- The US government references used are as follows:+-- <http://nist.gov/pml/wmd/metric/upload/SP1038.pdf>+-- <http://nist.gov/pml/wmd/pubs/upload/appc-14-hb44-final.pdf>+-----------------------------------------------------------------------------++module Data.Units.US (+  -- * Lengths+  Angstrom(..), Mil(..), Point(..), Pica(..),+  Inch(..), Foot(..), Yard(..), Mile(..), NauticalMile(..),++  -- * Velocity+  Knot(..),++  -- * Area+  Survey.Acre(..),++  -- * Volume+  -- | These are all /liquid/ measures. Solid measures are /different/.+  Liq.Teaspoon(..), Liq.Tablespoon(..), Liq.FluidOunce(..),+  Liq.Cup(..), Liq.Pint(..), Liq.Quart(..), Liq.Gallon(..),++  -- * Mass+  -- | These are all in the avoirdupois system+  Avdp.Ounce(..), Avdp.Pound(..), Avdp.Ton(..),++  -- * Pressure+  Atmosphere(..), Bar(..),++  -- * Energy+  FoodCalorie(..), Therm(..), Btu(..),++  -- * Power+  Horsepower(..)+  ) where++import Data.Units.US.Misc+import qualified Data.Units.US.Survey      as Survey+import qualified Data.Units.US.Liquid      as Liq+import qualified Data.Units.US.Avoirdupois as Avdp
+ Data/Units/US/Apothecaries.hs view
@@ -0,0 +1,46 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.US.Apothecaries+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- This module defines apothecaries' measures of mass. These measures+-- are rarely used.+--+-- Included are all units mentioned here:+-- <http://en.wikipedia.org/wiki/United_States_customary_units>+-- Where possible, conversion rates have been independently verified+-- at a US government website. However, Wikipedia's base is /much/+-- better organized than any government resource immediately available.+-- The US government references used are as follows:+-- <http://nist.gov/pml/wmd/metric/upload/SP1038.pdf>+-- <http://nist.gov/pml/wmd/pubs/upload/appc-14-hb44-final.pdf>+-----------------------------------------------------------------------------++module Data.Units.US.Apothecaries (+  module Data.Units.US.Apothecaries,++  -- | The apothecaries' grain is the same as the avoirdupois grain.+  Grain(..),++  -- | The apothecaries' ounce and pound are the troy ounce and pound.+  Ounce(..), Pound(..)+  ) where++import Data.Metrology.TH+import Data.Units.US.Avoirdupois ( Grain(..) )+import Data.Units.US.Troy ( Ounce(..), Pound(..) )++import Language.Haskell.TH++declareDerivedUnit "Scruple" [t| Grain |] 20   (Just "sap")+declareDerivedUnit "Dram"    [t| Grain |] 60   (Just "drap")++-- | Includes 'Grain', 'Scruple', 'Dram', 'Ounce', and 'Pound'.+apothecariesMassMeasures :: [Name]+apothecariesMassMeasures = [ ''Grain, ''Scruple, ''Dram, ''Ounce, ''Pound ]
+ Data/Units/US/Avoirdupois.hs view
@@ -0,0 +1,50 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.US.Avoirdupois+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- This module defines avoirdupois measures of mass. The avoirdupois+-- system is the one most commonly used in the US.+--+-- Included are all units mentioned here:+-- <http://en.wikipedia.org/wiki/United_States_customary_units>+-- Where possible, conversion rates have been independently verified+-- at a US government website. However, Wikipedia's base is /much/+-- better organized than any government resource immediately available.+-- The US government references used are as follows:+-- <http://nist.gov/pml/wmd/metric/upload/SP1038.pdf>+-- <http://nist.gov/pml/wmd/pubs/upload/appc-14-hb44-final.pdf>+-----------------------------------------------------------------------------++module Data.Units.US.Avoirdupois where++import Data.Metrology.TH+import Data.Units.SI ( Gram )++import Language.Haskell.TH++declareDerivedUnit "Pound"             [t| Gram  |] 453.59237    (Just "lb")++declareDerivedUnit "Grain"             [t| Pound |] (1/7000)     (Just "gr")+declareDerivedUnit "Dram"              [t| Grain |] (27 + 11/32) (Just "dr")+declareDerivedUnit "Ounce"             [t| Pound |] (1/16)       (Just "oz")+declareDerivedUnit "Hundredweight"     [t| Pound |] 100          (Just "cwt")+declareDerivedUnit "LongHundredweight" [t| Pound |] 112          (Just "longcwt")+declareDerivedUnit "Ton"               [t| Pound |] 2000         (Just "ton")+declareDerivedUnit "LongTon"           [t| Pound |] 2240         (Just "longton")++-- | Includes 'Ounce', 'Pound', 'Ton'+commonMassMeasures :: [Name]+commonMassMeasures = [ ''Ounce, ''Pound, ''Ton]++-- | Includes 'Grain', 'Dram', 'Hundredweight', 'LongHundredweight',+-- and 'LongTon'+otherMassMeasures :: [Name]+otherMassMeasures = [ ''Grain, ''Dram, ''Hundredweight, ''LongHundredweight+                    , ''LongTon ]
+ Data/Units/US/DryVolume.hs view
@@ -0,0 +1,47 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.US.DryVolume+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- This module defines dry volume measures as used in the USA.+--+-- Included are all units mentioned here:+-- <http://en.wikipedia.org/wiki/United_States_customary_units>+-- Where possible, conversion rates have been independently verified+-- at a US government website. However, Wikipedia's base is /much/+-- better organized than any government resource immediately available.+-- The US government references used are as follows:+-- <http://nist.gov/pml/wmd/metric/upload/SP1038.pdf>+-- <http://nist.gov/pml/wmd/pubs/upload/appc-14-hb44-final.pdf>+-----------------------------------------------------------------------------++module Data.Units.US.DryVolume where++import Data.Metrology+import Data.Metrology.TH+import Data.Units.US.Misc++import Language.Haskell.TH++declareDerivedUnit "Gallon"      [t| Inch :^ Three |] 268.8025 (Just "gal")+declareDerivedUnit "Quart"       [t| Gallon        |] (1/4)    (Just "qt")+declareDerivedUnit "Pint"        [t| Quart         |] (1/2)    (Just "pt")+declareDerivedUnit "Peck"        [t| Gallon        |] 2        (Just "pk")+declareDerivedUnit "Bushel"      [t| Peck          |] 4        (Just "bu")+declareDerivedUnit "Barrel"      [t| Inch :^ Three |] 7056     (Just "bbl")+declareDerivedUnit "Cord"        [t| Foot :^ Three |] 128      (Just "cd")+declareDerivedUnit "BoardFoot"   [t| Foot :^ Three |] (1/12)   (Just "FBM")+declareDerivedUnit "RegisterTon" [t| Foot :^ Three |] 100      (Just "RT")++declareDerivedUnit "CranberryBarrel" [t| Inch :^ Three |] 5826 (Just "bbl")++-- | Includes all measures in this file, except 'CranberryBarrel'.+dryVolumeMeasures :: [Name]+dryVolumeMeasures = [ ''Pint, ''Quart, ''Gallon, ''Peck, ''Bushel+                    , ''Barrel, ''Cord, ''BoardFoot, ''RegisterTon ]
+ Data/Units/US/Liquid.hs view
@@ -0,0 +1,60 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.US.Liquid+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- This module defines liquid volume measures as used in the USA.+-- Note that liquid volumes in the USA differ both from solid volumes+-- in the USA and from liquid volumes in the UK.+--+-- Included are all units mentioned here:+-- <http://en.wikipedia.org/wiki/United_States_customary_units>+-- Where possible, conversion rates have been independently verified+-- at a US government website. However, Wikipedia's base is /much/+-- better organized than any government resource immediately available.+-- The US government references used are as follows:+-- <http://nist.gov/pml/wmd/metric/upload/SP1038.pdf>+-- <http://nist.gov/pml/wmd/pubs/upload/appc-14-hb44-final.pdf>+-----------------------------------------------------------------------------++module Data.Units.US.Liquid where++import Data.Metrology+import Data.Metrology.TH+import Data.Units.US.Misc++import Language.Haskell.TH++declareDerivedUnit "Gallon"     [t| Inch :^ Three |] 231     (Just "gal")++declareDerivedUnit "FluidOunce" [t| Gallon        |] (1/128) (Just "floz")+declareDerivedUnit "Gill"       [t| FluidOunce    |] 4       (Just "gi")+declareDerivedUnit "Cup"        [t| FluidOunce    |] 8       (Just "cp")+declareDerivedUnit "Pint"       [t| FluidOunce    |] 16      (Just "pt")+declareDerivedUnit "Quart"      [t| Gallon        |] (1/4)   (Just "qt")++declareDerivedUnit "Teaspoon"   [t| FluidOunce    |] (1/6)   (Just "tsp")+declareDerivedUnit "Tablespoon" [t| Teaspoon      |] 3       (Just "Tbsp")+declareDerivedUnit "Shot"       [t| Tablespoon    |] 3       (Just "jig")+declareDerivedUnit "Minim"      [t| Teaspoon      |] (1/80)  (Just "min")+declareDerivedUnit "Dram"       [t| Minim         |] 60      (Just "fldr")++declareDerivedUnit "Hogshead"   [t| Gallon        |] 63      (Just "hogshead")+declareDerivedUnit "Barrel"     [t| Hogshead      |] (1/2)   (Just "bbl")+declareDerivedUnit "OilBarrel"  [t| Gallon        |] 42      (Just "bbl")++-- | As shown on Wikipedia: <http://en.wikipedia.org/wiki/United_States_customary_units>+commonLiquidMeasures :: [Name]+commonLiquidMeasures = [ ''Teaspoon, ''Tablespoon, ''FluidOunce, ''Cup, ''Pint+                       , ''Quart, ''Gallon ]++-- | Includes the rest of the measures in this file.+otherLiquidMeasures :: [Name]+otherLiquidMeasures = [ ''Minim, ''Dram, ''Shot, ''Gill, ''Barrel+                      , ''OilBarrel, ''Hogshead ]
+ Data/Units/US/Misc.hs view
@@ -0,0 +1,83 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.US.Misc+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- This module defines American customary units that don't fit into+-- other categories.+--+-- Included are all units mentioned here:+-- <http://en.wikipedia.org/wiki/United_States_customary_units>+-- Where possible, conversion rates have been independently verified+-- at a US government website. However, Wikipedia's base is /much/+-- better organized than any government resource immediately available.+-- The US government references used are as follows:+-- <http://nist.gov/pml/wmd/metric/upload/SP1038.pdf>+-- <http://nist.gov/pml/wmd/pubs/upload/appc-14-hb44-final.pdf>+-----------------------------------------------------------------------------++module Data.Units.US.Misc (+  module Data.Units.US.Misc,+  Maxwell(..)+  ) where++import Data.Metrology+import Data.Metrology.TH++import Data.Units.SI+import Data.Units.SI.Prefixes+import Data.Units.CGS+import Data.Constants.Math++import Language.Haskell.TH++declareDerivedUnit "Foot"       [t| Meter         |] 0.3048    (Just "ft")+declareDerivedUnit "Inch"       [t| Foot          |] (1/12)    (Just "in")+declareDerivedUnit "Yard"       [t| Foot          |] 3         (Just "yd")+declareDerivedUnit "Mile"       [t| Foot          |] 5280      (Just "mi")+declareDerivedUnit "Angstrom"   [t| Nano :@ Meter |] 0.1       (Just "Å")+declareDerivedUnit "Hand"       [t| Inch          |] 4         (Just "hand")+declareDerivedUnit "Mil"        [t| Inch          |] 0.001     (Just "mil")++declareDerivedUnit "Point"      [t| Inch   |] 0.013837    (Just "p")+declareDerivedUnit "Pica"       [t| Point  |] 12          (Just "P")++declareDerivedUnit "Fathom"       [t| Yard       |]    2     (Just "ftm")+declareDerivedUnit "Cable"        [t| Fathom     |]    120   (Just "cb")+declareDerivedUnit "NauticalMile" [t| Kilo :@ Meter |] 1.852 (Just "NM")++declareDerivedUnit "Knot"       [t| NauticalMile :/ Hour |] 1 (Just "kn")++declareDerivedUnit "Atmosphere" [t| Kilo :@ Pascal |]  101.325 (Just "atm")+declareDerivedUnit "Bar"        [t| Kilo :@ Pascal |]  100     (Just "bar")+declareDerivedUnit "MillimeterOfMercury"+                                [t| Pascal |] 133.322387415 (Just "mmHg")+declareDerivedUnit "Torr"       [t| Atmosphere |]      (1/760) (Just "Torr")+++declareDerivedUnit "Calorie"     [t| Joule           |] 4.184          (Just "cal")+declareDerivedUnit "FoodCalorie" [t| Kilo :@ Calorie |] 1              (Just "Cal")+declareDerivedUnit "Therm"       [t| Mega :@ Joule   |] 105.4804       (Just "thm")+declareDerivedUnit "Btu"         [t| Joule           |] 1055.05585262  (Just "btu")++declareDerivedUnit "Horsepower" [t| Watt   |] 746       (Just "hp")++declareDerivedUnit "Rankine"    [t| Kelvin |] (5/9)  (Just "°R")++declareDerivedUnit "PoundForce" [t| Newton |] 4.4482216152605 (Just "lbf")++declareDerivedUnit "Slug"       [t| PoundForce :* (Second :^ Two) :/ Foot |]+                                1 (Just "slug")++declareDerivedUnit "Oersted"    [t| Ampere :/ Meter |]+                                (1000 / (4 * piR)) (Just "Oe")++-- | Standard lengths: 'Foot', 'Inch', 'Yard', and 'Mile'+lengths :: [Name]+lengths = [ ''Foot, ''Inch, ''Yard, ''Mile ]
+ Data/Units/US/Survey.hs view
@@ -0,0 +1,53 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.US.Survey+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- This module defines survey measures as used in the USA.+-- Note that a survey foot is ever so slightly different from a standard+-- foot.+--+-- Included are all units mentioned here:+-- <http://en.wikipedia.org/wiki/United_States_customary_units>+-- Where possible, conversion rates have been independently verified+-- at a US government website. However, Wikipedia's base is /much/+-- better organized than any government resource immediately available.+-- The US government references used are as follows:+-- <http://nist.gov/pml/wmd/metric/upload/SP1038.pdf>+-- <http://nist.gov/pml/wmd/pubs/upload/appc-14-hb44-final.pdf>+-----------------------------------------------------------------------------++module Data.Units.US.Survey where++import Data.Metrology+import Data.Metrology.TH+import Data.Units.SI++import Language.Haskell.TH++declareDerivedUnit "Foot"    [t| Meter    |] (1200/3937) (Just "ft")+declareDerivedUnit "Link"    [t| Foot     |] 0.66        (Just "li")+declareDerivedUnit "Rod"     [t| Link     |] 25          (Just "rd")+declareDerivedUnit "Chain"   [t| Rod      |] 4           (Just "ch")+declareDerivedUnit "Furlong" [t| Chain    |] 10          (Just "fur")+declareDerivedUnit "Mile"    [t| Furlong  |] 8           (Just "mi")+declareDerivedUnit "League"  [t| Mile     |] 3           (Just "lea")++-- | Includes all the lengths above.+surveyLengths :: [Name]+surveyLengths = [ ''Foot, ''Link, ''Rod, ''Chain, ''Furlong+                , ''Mile, ''League ]++declareDerivedUnit "Acre"     [t| Foot :^ Two |] 43560 (Just "acre")+declareDerivedUnit "Section"  [t| Acre |]        640   (Just "section")+declareDerivedUnit "Township" [t| Section |]     36    (Just "twp")++-- | Includes all the areas above.+surveyAreas :: [Name]+surveyAreas = [ ''Acre, ''Section, ''Township ]
+ Data/Units/US/Troy.hs view
@@ -0,0 +1,43 @@+{-# LANGUAGE TemplateHaskell, TypeFamilies, TypeOperators #-}++-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Units.US.Troy+-- Copyright   :  (C) 2013 Richard Eisenberg+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  Richard Eisenberg (rae@cs.brynmawr.edu)+-- Stability   :  experimental+-- Portability :  non-portable+--+-- This module defines troy measures of mass. The troy+-- system is most often used when measuring precious metals.+--+-- Included are all units mentioned here:+-- <http://en.wikipedia.org/wiki/United_States_customary_units>+-- Where possible, conversion rates have been independently verified+-- at a US government website. However, Wikipedia's base is /much/+-- better organized than any government resource immediately available.+-- The US government references used are as follows:+-- <http://nist.gov/pml/wmd/metric/upload/SP1038.pdf>+-- <http://nist.gov/pml/wmd/pubs/upload/appc-14-hb44-final.pdf>+-----------------------------------------------------------------------------++module Data.Units.US.Troy (+  module Data.Units.US.Troy,++  -- | The avoirdupois grain is the same as the troy grain+  Grain(..)+  ) where++import Data.Metrology.TH+import Data.Units.US.Avoirdupois ( Grain(..) )++import Language.Haskell.TH++declareDerivedUnit "Pennyweight" [t| Grain       |] 24 (Just "dwt")+declareDerivedUnit "Ounce"       [t| Pennyweight |] 20 (Just "ozt")+declareDerivedUnit "Pound"       [t| Ounce       |] 12 (Just "lbt")++-- | Includes 'Grain', 'Pennyweight', 'Ounce', and 'Pound'+troyMassMeasures :: [Name]+troyMassMeasures = [ ''Grain, ''Pennyweight, ''Ounce, ''Pound ]
units-defs.cabal view
@@ -1,45 +1,67 @@ name:           units-defs-version:        1.0.1+version:        2.2.1 cabal-version:  >= 1.10 synopsis:       Definitions for use with the units package homepage:       http://github.com/goldfirere/units-defs category:       Physics-author:         Richard Eisenberg <eir@cis.upenn.edu>, Takayuki Muranushi <muranushi@gmail.com>-maintainer:     Richard Eisenberg <eir@cis.upenn.edu>, Takayuki Muranushi <muranushi@gmail.com>+author:         Richard Eisenberg <rae@richarde.dev>, Takayuki Muranushi <muranushi@gmail.com>+maintainer:     Richard Eisenberg <rae@richarde.dev>, Takayuki Muranushi <muranushi@gmail.com> bug-reports:    https://github.com/goldfirere/units-defs/issues stability:      experimental extra-source-files: README.md, CHANGES.md license:        BSD3 license-file:   LICENSE build-type:     Simple+Tested-With: GHC == 7.8.4, GHC == 7.10.2, GHC == 7.10.3, GHC == 8.0.1, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.1, GHC == 8.6.3, GHC == 8.8.1, GHC == 8.10.4, GHC == 9.0.1 description:-     This package provides system definitions for use with the separate     @units@ package. See the individual modules for details.      User contributions to this package are strongly encouraged. Please     submit pull requests! -source-repository this+source-repository head   type:     git-  location: https://github.com/goldfirere/units-defs.git-  tag:      v1.0.1+  location: https://github.com/goldfirere/units.git  library   build-depends:             base >= 4.7 && < 5,-      units >= 2.0 && < 3+      units >= 2.2 && < 3,+      template-haskell   exposed-modules:-    Data.Metrology.SI,-    Data.Metrology.SI.Mono,-    Data.Metrology.SI.Poly,-    Data.Metrology.SI.Prefixes,-    Data.Metrology.SI.MonoTypes, -    Data.Metrology.SI.Units,-    Data.Metrology.SI.Dims,+    Data.Constants.Mechanics+    Data.Constants.Math+    Data.Dimensions.SI+    Data.Metrology.SI+    Data.Metrology.SI.Mono+    Data.Metrology.SI.Poly+    Data.Metrology.SI.MonoTypes     Data.Metrology.SI.PolyTypes---    Data.Metrology.Imperial.Types---    Data.Metrology.Imperial.Units+    Data.Units.SI+    Data.Units.SI.Prefixes+    Data.Units.SI.Parser+    Data.Units.CGS+    Data.Units.US+    Data.Units.US.Apothecaries+    Data.Units.US.Avoirdupois+    Data.Units.US.DryVolume+    Data.Units.US.Liquid+    Data.Units.US.Misc+    Data.Units.US.Survey+    Data.Units.US.Troy+    Data.Units.PreciousMetals+    Data.Units.Eurocard+    Data.Units.Imperial+    Data.Units.Imperial.Area+    Data.Units.Imperial.Length+    Data.Units.Imperial.Misc+    Data.Units.Imperial.Nautical+    Data.Units.Imperial.Survey+    Data.Units.Imperial.Volume+    Data.Units.Imperial.Weight+    Data.Units.Astronomical    default-language:   Haskell2010-+  other-extensions:   TemplateHaskell+  ghc-options:        -Wall