packages feed

units-defs 2.2 → 2.2.1

raw patch · 13 files changed

+476/−8 lines, 13 filesdep ~base

Dependency ranges changed: base

Files

CHANGES.md view
@@ -1,3 +1,8 @@+Version 2.2.1+-------------+* Actually export Imperial units, along with bugfixes (thanks to @Bebere).+* Export Eurocard units (thanks to @mlang).+ Version 2.2 ----------- 
Data/Units/CGS.hs view
@@ -1,5 +1,5 @@ {-# LANGUAGE PatternSynonyms, TemplateHaskell, TypeOperators,-             TypeFamilies #-}+             TypeFamilies, CPP #-}  ----------------------------------------------------------------------------- -- |@@ -33,12 +33,16 @@  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"
+ 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/SI.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TypeFamilies, TypeOperators, PatternSynonyms, TemplateHaskell #-}+{-# LANGUAGE TypeFamilies, TypeOperators, PatternSynonyms, TemplateHaskell, CPP #-}  ----------------------------------------------------------------------------- -- |@@ -39,14 +39,18 @@  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")@@ -73,7 +77,9 @@  type Litre = Liter +#if __GLASGOW_HASKELL__ >= 710 pattern Litre :: Litre+#endif pattern Litre = Liter  declareDerivedUnit "Newton"    [t| Gram :* Meter :/ (Second :^ Two) |]  1000  (Just "N")@@ -95,7 +101,7 @@ 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 +-- 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.@@ -110,7 +116,9 @@ 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
units-defs.cabal view
@@ -1,5 +1,5 @@ name:           units-defs-version:        2.2+version:        2.2.1 cabal-version:  >= 1.10 synopsis:       Definitions for use with the units package homepage:       http://github.com/goldfirere/units-defs@@ -12,6 +12,7 @@ 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.@@ -19,14 +20,13 @@     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:      v2.2+  location: https://github.com/goldfirere/units.git  library   build-depends:      -      base >= 4.8 && < 5,+      base >= 4.7 && < 5,       units >= 2.2 && < 3,       template-haskell   exposed-modules:@@ -51,6 +51,15 @@     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