diff --git a/dimensional-dk.cabal b/dimensional-dk.cabal index 60db6e2a..2bf40735 100644 --- a/dimensional-dk.cabal +++ b/dimensional-dk.cabal @@ -54,7 +54,11 @@ library Numeric.Units.Dimensional.DK.Dimensions, Numeric.Units.Dimensional.DK.Dimensions.TermLevel, Numeric.Units.Dimensional.DK.Dimensions.TypeLevel, - Numeric.Units.Dimensional.DK.Functor + Numeric.Units.Dimensional.DK.Functor, + Numeric.Units.Dimensional.DK.SI, + Numeric.Units.Dimensional.DK.SI.Prelude, + Numeric.Units.Dimensional.DK.SI.SIUnits, + Numeric.Units.Dimensional.DK.SI.Quantities test-suite tests type: exitcode-stdio-1.0 @@ -78,4 +82,4 @@ benchmark simple dimensional-dk default-language: Haskell2010 ghc-options: -O2 - \ No newline at end of file + diff --git a/examples/NewtonianMechanics.hs b/examples/NewtonianMechanics.hs index 94338a6f..5d336720 100644 --- a/examples/NewtonianMechanics.hs +++ b/examples/NewtonianMechanics.hs @@ -30,8 +30,8 @@ rotationalMomentum i w = i * w rotationalPower :: (Num a) => Torque a -> AngularVelocity a -> Power a rotationalPower t w = t * w -torque :: (Num a) => Force a -> Length a -> Torque a -torque r f = r * f +torque :: (Fractional a) => Force a -> Length a -> Torque a +torque r f = r * f / (1 *~ radian) torqueFromChangeInMomentum :: (Fractional a) => AngularMomentum a -> Time a -> Torque a torqueFromChangeInMomentum dL dt = dL / dt diff --git a/src/Numeric/Units/Dimensional/DK.hs b/src/Numeric/Units/Dimensional/DK.hs index 52540f1b..108fa88c 100644 --- a/src/Numeric/Units/Dimensional/DK.hs +++ b/src/Numeric/Units/Dimensional/DK.hs @@ -199,7 +199,7 @@ module Numeric.Units.Dimensional.DK Dimension (Dim), -- ** Dimension Arithmetic -- $dimension-arithmetic - type (*), type (/), type (^), Root, Recip, + type (*), type (/), type (^), Root, Recip, type SIDim, type ToSIDim, -- ** Term Level Representation of Dimensions -- $dimension-terms Dimension' (Dim'), HasDimension(..), KnownDimension, @@ -209,20 +209,22 @@ module Numeric.Units.Dimensional.DK negate, abs, nroot, sqrt, cbrt, -- ** Transcendental Functions exp, log, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh, atan2, + -- ** Dealing with Angles + removeAngles, coerceAngles, -- ** Operations on Collections -- $collections (*~~), (/~~), sum, mean, dimensionlessLength, nFromTo, -- * Dimension Synonyms -- $dimension-synonyms - DOne, DLength, DMass, DTime, DElectricCurrent, DThermodynamicTemperature, DAmountOfSubstance, DLuminousIntensity, + DOne, DLength, DMass, DTime, DElectricCurrent, DThermodynamicTemperature, DAmountOfSubstance, DLuminousIntensity, DPlaneAngle, -- * Quantity Synonyms -- $quantity-synonyms - Dimensionless, Length, Mass, Time, ElectricCurrent, ThermodynamicTemperature, AmountOfSubstance, LuminousIntensity, + Dimensionless, Length, Mass, Time, ElectricCurrent, ThermodynamicTemperature, AmountOfSubstance, LuminousIntensity, PlaneAngle, -- * Constants -- $constants _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, pi, tau, -- * Constructing Units - prefix, siUnit, one, + prefix, baseUnit, siUnit, one, -- * On 'Functor', and Conversion Between Number Representations -- $functor dmap, changeRep @@ -385,6 +387,7 @@ type ElectricCurrent = Quantity DElectricCurrent type ThermodynamicTemperature = Quantity DThermodynamicTemperature type AmountOfSubstance = Quantity DAmountOfSubstance type LuminousIntensity = Quantity DLuminousIntensity +type PlaneAngle = Quantity DPlaneAngle {- $dimension-arithmetic When performing arithmetic on units and quantities the arithmetics @@ -581,16 +584,10 @@ We continue by defining elementary functions on 'Dimensionless' that may be obviously useful. -} -exp, log, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh +exp, log, sinh, cosh, tanh, asinh, acosh, atanh :: Floating a => Dimensionless a -> Dimensionless a exp = fmap Prelude.exp log = fmap Prelude.log -sin = fmap Prelude.sin -cos = fmap Prelude.cos -tan = fmap Prelude.tan -asin = fmap Prelude.asin -acos = fmap Prelude.acos -atan = fmap Prelude.atan sinh = fmap Prelude.sinh cosh = fmap Prelude.cosh tanh = fmap Prelude.tanh @@ -598,22 +595,57 @@ asinh = fmap Prelude.asinh acosh = fmap Prelude.acosh atanh = fmap Prelude.atanh +sin, cos, tan :: Floating a => PlaneAngle a -> Dimensionless a +sin = (*~ one) . Prelude.sin . (/~ baseUnit) +cos = (*~ one) . Prelude.cos . (/~ baseUnit) +tan = (*~ one) . Prelude.tan . (/~ baseUnit) + +asin, acos, atan :: Floating a => Dimensionless a -> PlaneAngle a +asin = (*~ baseUnit) . Prelude.asin . (/~ one) +acos = (*~ baseUnit) . Prelude.acos . (/~ one) +atan = (*~ baseUnit) . Prelude.atan . (/~ one) + +-- | Removes angular dimensions from a dimensional value by equating radians +-- with the dimensionless quantity one. +removeAngles :: Dimensional v ('Dim l m t i th n j pa) a -> Dimensional v (SIDim l m t i th n j) a +removeAngles = coerceAngles + +-- | Equates values whose dimensions differ in plane angles by equating +-- radians with the dimensionless quantity one. +-- +-- See `removeAngles`, which offers a more specific result type, if you are only interested +-- in ignoring angle dimensions. +coerceAngles :: Dimensional v ('Dim l m t i th n j pa) a -> Dimensional v ('Dim l m t i th n j pa') a +coerceAngles = coerce + (**) :: Floating a => Dimensionless a -> Dimensionless a -> Dimensionless a Dimensional x ** Dimensional y = Dimensional (x Prelude.** y) {- For 'atan2' the operands need not be dimensionless but they must be -of the same type. The result will of course always be dimensionless. +of the same type. The result will of course always be a plane angle. -} -atan2 :: RealFloat a => Quantity d a -> Quantity d a -> Dimensionless a +atan2 :: RealFloat a => Quantity d a -> Quantity d a -> PlaneAngle a atan2 (Dimensional y) (Dimensional x) = Dimensional (Prelude.atan2 y x) +-- | A polymorphic 'Unit' which can be used in place of the coherent +-- base unit of any dimension. This allows polymorphic quantity +-- creation and destruction without exposing the 'Dimensional' constructor. +-- +-- `siUnit` is similar but does not include the radians associated +-- with plane angles. +baseUnit :: Num a => Unit d a +baseUnit = Dimensional 1 + -- | A polymorphic 'Unit' which can be used in place of the coherent -- SI base unit of any dimension. This allows polymorphic quantity -- creation and destruction without exposing the 'Dimensional' constructor. -siUnit :: Num a => Unit d a -siUnit = Dimensional 1 +-- +-- `baseUnit` is similar but includes the radians associated +-- with plane angles. +siUnit :: Num a => Unit (SIDim l m t i th n j) a +siUnit = removeAngles baseUnit {- The only unit we will define in this module is 'one'. @@ -626,7 +658,7 @@ The only unit we will define in this module is 'one'. -- appear in expressions. However, for us it is necessary to use 'one' -- as we would any other unit to perform the "boxing" of dimensionless values. one :: Num a => Unit DOne a -one = siUnit +one = baseUnit {- $constants For convenience we define some constants for small integer values @@ -639,7 +671,7 @@ good measure. -- it to express zero Length or Capacitance or Velocity etc, in addition -- to the dimensionless value zero. _0 :: Num a => Quantity d a -_0 = 0 *~ siUnit +_0 = 0 *~ baseUnit _1, _2, _3, _4, _5, _6, _7, _8, _9 :: (Num a) => Dimensionless a _1 = 1 *~ one @@ -704,7 +736,7 @@ even a requirement. -} instance (KnownDimension d, Show a) => Show (Quantity d a) where show q@(Dimensional x) = let powers = asList $ dimension q - units = ["m", "kg", "s", "A", "K", "mol", "cd"] + units = ["m", "kg", "s", "A", "K", "mol", "cd", "rad", "sr"] dims = concat $ zipWith dimUnit units powers in show x ++ dims diff --git a/src/Numeric/Units/Dimensional/DK/Dimensions/TermLevel.hs b/src/Numeric/Units/Dimensional/DK/Dimensions/TermLevel.hs index 2cf7e968..0bfa1298 100644 --- a/src/Numeric/Units/Dimensional/DK/Dimensions/TermLevel.hs +++ b/src/Numeric/Units/Dimensional/DK/Dimensions/TermLevel.hs @@ -9,7 +9,7 @@ Portability: GHC only This module defines physical dimensions expressed in terms of -the SI base dimensions, including arithmetic. +the SI base dimensions along with plane angles, including arithmetic. -} module Numeric.Units.Dimensional.DK.Dimensions.TermLevel @@ -22,7 +22,7 @@ module Numeric.Units.Dimensional.DK.Dimensions.TermLevel (*), (/), (^), recip, -- * Synonyms for Base Dimensions dOne, - dLength, dMass, dTime, dElectricCurrent, dThermodynamicTemperature, dAmountOfSubstance, dLuminousIntensity, + dLength, dMass, dTime, dElectricCurrent, dThermodynamicTemperature, dAmountOfSubstance, dLuminousIntensity, dPlaneAngle, -- * Deconstruction asList ) @@ -32,10 +32,11 @@ import Data.Monoid (Monoid(..)) import Prelude (id, (+), (-), Int, Show, Eq, Ord) import qualified Prelude as P --- | A physical dimension, encoded as 7 integers, representing a factorization of the dimension into the --- 7 SI base dimensions. By convention they are stored in the same order as +-- | A physical dimension, encoded as 8 integers, representing a factorization of the dimension into the +-- 7 SI base dimensions, along with the dimensions of plane angle. +-- By convention they are stored in the same order as -- in the 'Numeric.Units.Dimensional.DK.Dimensions.TypeLevel.Dimension' data kind. -data Dimension' = Dim' !Int !Int !Int !Int !Int !Int !Int +data Dimension' = Dim' !Int !Int !Int !Int !Int !Int !Int !Int deriving (Show, Eq, Ord) -- | The monoid of dimensions under multiplication. @@ -53,16 +54,17 @@ instance HasDimension Dimension' where -- | The dimension of dimensionless values. dOne :: Dimension' -dOne = Dim' 0 0 0 0 0 0 0 - -dLength, dMass, dTime, dElectricCurrent, dThermodynamicTemperature, dAmountOfSubstance, dLuminousIntensity :: Dimension' -dLength = Dim' 1 0 0 0 0 0 0 -dMass = Dim' 0 1 0 0 0 0 0 -dTime = Dim' 0 0 1 0 0 0 0 -dElectricCurrent = Dim' 0 0 0 1 0 0 0 -dThermodynamicTemperature = Dim' 0 0 0 0 1 0 0 -dAmountOfSubstance = Dim' 0 0 0 0 0 1 0 -dLuminousIntensity = Dim' 0 0 0 0 0 0 1 +dOne = Dim' 0 0 0 0 0 0 0 0 + +dLength, dMass, dTime, dElectricCurrent, dThermodynamicTemperature, dAmountOfSubstance, dLuminousIntensity, dPlaneAngle :: Dimension' +dLength = Dim' 1 0 0 0 0 0 0 0 +dMass = Dim' 0 1 0 0 0 0 0 0 +dTime = Dim' 0 0 1 0 0 0 0 0 +dElectricCurrent = Dim' 0 0 0 1 0 0 0 0 +dThermodynamicTemperature = Dim' 0 0 0 0 1 0 0 0 +dAmountOfSubstance = Dim' 0 0 0 0 0 1 0 0 +dLuminousIntensity = Dim' 0 0 0 0 0 0 1 0 +dPlaneAngle = Dim' 0 0 0 0 0 0 0 1 {- We will reuse the operators and function names from the Prelude. @@ -75,21 +77,21 @@ infixl 7 *, / -- | Forms the product of two dimensions. (*) :: Dimension' -> Dimension' -> Dimension' -(Dim' l m t i th n j) * (Dim' l' m' t' i' th' n' j') = Dim' (l + l') (m + m') (t + t') (i + i') (th + th') (n + n') (j + j') +(Dim' l m t i th n j pa) * (Dim' l' m' t' i' th' n' j' pa') = Dim' (l + l') (m + m') (t + t') (i + i') (th + th') (n + n') (j + j') (pa + pa') -- | Forms the quotient of two dimensions. (/) :: Dimension' -> Dimension' -> Dimension' -(Dim' l m t i th n j) / (Dim' l' m' t' i' th' n' j') = Dim' (l - l') (m - m') (t - t') (i - i') (th - th') (n - n') (j - j') +(Dim' l m t i th n j pa) / (Dim' l' m' t' i' th' n' j' pa') = Dim' (l - l') (m - m') (t - t') (i - i') (th - th') (n - n') (j - j') (pa - pa') -- | Raises a dimension to an integer power. (^) :: Dimension' -> Int -> Dimension' -(Dim' l m t i th n j) ^ x = Dim' (x P.* l) (x P.* m) (x P.* t) (x P.* i) (x P.* th) (x P.* n) (x P.* j) +(Dim' l m t i th n j pa) ^ x = Dim' (x P.* l) (x P.* m) (x P.* t) (x P.* i) (x P.* th) (x P.* n) (x P.* j) (x P.* pa) -- | Forms the reciprocal of a dimension. recip :: Dimension' -> Dimension' recip = (dOne /) --- | Converts a dimension to a list of 7 integers, representing the exponent associated with each --- of the 7 SI base dimensions in the standard order. +-- | Converts a dimension to a list of 9 integers, representing the exponent associated with each +-- of the 7 SI base dimensions in the standard order, followed by the dimensions of plane and spherical angles. asList :: Dimension' -> [Int] -asList (Dim' l m t i th n j) = [l, m, t, i, th, n, j] +asList (Dim' l m t i th n j pa) = [l, m, t, i, th, n, j, pa] diff --git a/src/Numeric/Units/Dimensional/DK/Dimensions/TypeLevel.hs b/src/Numeric/Units/Dimensional/DK/Dimensions/TypeLevel.hs index 8f257835..0a6684b4 100644 --- a/src/Numeric/Units/Dimensional/DK/Dimensions/TypeLevel.hs +++ b/src/Numeric/Units/Dimensional/DK/Dimensions/TypeLevel.hs @@ -18,7 +18,7 @@ Portability: GHC only This module defines type-level physical dimensions expressed in terms of -the SI base dimensions using 'Numeric.NumType.DK.NumType' for type-level integers. +the SI base dimensions along with plane angles using 'Numeric.NumType.DK.NumType' for type-level integers. Type-level arithmetic, synonyms for the base dimensions, and conversion to the term-level are included. -} @@ -30,7 +30,9 @@ module Numeric.Units.Dimensional.DK.Dimensions.TypeLevel type (*), type (/), type (^), type Recip, type Root, -- * Synonyms for Base Dimensions DOne, - DLength, DMass, DTime, DElectricCurrent, DThermodynamicTemperature, DAmountOfSubstance, DLuminousIntensity, + DLength, DMass, DTime, DElectricCurrent, DThermodynamicTemperature, DAmountOfSubstance, DLuminousIntensity, DPlaneAngle, + -- * Conversion to SI Basis + type SIDim, type ToSIDim, -- * Conversion to Term Level type KnownDimension ) @@ -45,6 +47,7 @@ import qualified Numeric.NumType.DK.Integers as N import Numeric.Units.Dimensional.DK.Dimensions.TermLevel -- | Represents a physical dimension in the basis of the 7 SI base dimensions, +-- along with the dimensions of plane angle, -- where the respective dimensions are represented by type variables -- using the following convention. -- @@ -55,19 +58,21 @@ import Numeric.Units.Dimensional.DK.Dimensions.TermLevel -- * th: Thermodynamic temperature -- * n: Amount of substance -- * j: Luminous intensity +-- * pa: Plane angle -- -- For the equivalent term-level representation, see 'Dimension'' -data Dimension = Dim TypeInt TypeInt TypeInt TypeInt TypeInt TypeInt TypeInt +data Dimension = Dim TypeInt TypeInt TypeInt TypeInt TypeInt TypeInt TypeInt TypeInt -- | The type-level dimensions of dimensionless values. -type DOne = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero -type DLength = 'Dim 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero -type DMass = 'Dim 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero -type DTime = 'Dim 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero -type DElectricCurrent = 'Dim 'Zero 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero -type DThermodynamicTemperature = 'Dim 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero 'Zero -type DAmountOfSubstance = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero -type DLuminousIntensity = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 +type DOne = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero +type DLength = 'Dim 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero +type DMass = 'Dim 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero +type DTime = 'Dim 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero +type DElectricCurrent = 'Dim 'Zero 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero +type DThermodynamicTemperature = 'Dim 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero +type DAmountOfSubstance = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero 'Zero +type DLuminousIntensity = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero +type DPlaneAngle = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 {- We will reuse the operators and function names from the Prelude. @@ -83,16 +88,16 @@ infixl 7 *, / type family (a::Dimension) * (b::Dimension) where DOne * d = d d * DOne = d - ('Dim l m t i th n j) * ('Dim l' m' t' i' th' n' j') - = 'Dim (l + l') (m + m') (t + t') (i + i') (th + th') (n + n') (j + j') + ('Dim l m t i th n j pa) * ('Dim l' m' t' i' th' n' j' pa') + = 'Dim (l + l') (m + m') (t + t') (i + i') (th + th') (n + n') (j + j') (pa + pa') -- | Division of dimensions corresponds to subtraction of the base -- dimensions' exponents. type family (a::Dimension) / (d::Dimension) where d / DOne = d d / d = DOne - ('Dim l m t i th n j) / ('Dim l' m' t' i' th' n' j') - = 'Dim (l - l') (m - m') (t - t') (i - i') (th - th') (n - n') (j - j') + ('Dim l m t i th n j pa) / ('Dim l' m' t' i' th' n' j' pa') + = 'Dim (l - l') (m - m') (t - t') (i - i') (th - th') (n - n') (j - j') (pa - pa') -- | The reciprocal of a dimension is defined as the result of dividing 'DOne' by it, -- or of negating each of the base dimensions' exponents. @@ -107,8 +112,8 @@ type family (d::Dimension) ^ (x::TypeInt) where DOne ^ x = DOne d ^ 'Zero = DOne d ^ 'Pos1 = d - ('Dim l m t i th n j) ^ x - = 'Dim (l N.* x) (m N.* x) (t N.* x) (i N.* x) (th N.* x) (n N.* x) (j N.* x) + ('Dim l m t i th n j pa) ^ x + = 'Dim (l N.* x) (m N.* x) (t N.* x) (i N.* x) (th N.* x) (n N.* x) (j N.* x) (pa N.* x) -- | Roots of dimensions corresponds to division of the base dimensions' -- exponents by the order(?) of the root. @@ -117,8 +122,25 @@ type family (d::Dimension) ^ (x::TypeInt) where type family Root (d::Dimension) (x::TypeInt) where Root DOne x = DOne Root d 'Pos1 = d - Root ('Dim l m t i th n j) x - = 'Dim (l N./ x) (m N./ x) (t N./ x) (i N./ x) (th N./ x) (n N./ x) (j N./ x) + Root ('Dim l m t i th n j pa) x + = 'Dim (l N./ x) (m N./ x) (t N./ x) (i N./ x) (th N./ x) (n N./ x) (j N./ x) (pa N./ x) + +-- | Represents a physical dimension in the basis of the 7 SI base dimensions, +-- where the respective dimensions are represented by type variables +-- using the following convention. +-- +-- * l: Length +-- * m: Mass +-- * t: Time +-- * i: Electric current +-- * th: Thermodynamic temperature +-- * n: Amount of substance +-- * j: Luminous intensity +type SIDim l m t i th n j = 'Dim l m t i th n j 'Zero + +-- | Projects a 'Dimension' in the extended basis including plane angles to the SI basis. +type family ToSIDim (d :: Dimension) :: Dimension where + ToSIDim ('Dim l m t i th n j pa) = SIDim l m t i th n j -- | A KnownDimension is one for which we can construct a term-level representation. -- Each validly constructed type of kind 'Dimension' has a 'KnownDimension' instance. @@ -134,7 +156,8 @@ instance ( KnownTypeInt l , KnownTypeInt th , KnownTypeInt n , KnownTypeInt j - ) => HasDimension (Proxy ('Dim l m t i th n j)) + , KnownTypeInt pa + ) => HasDimension (Proxy ('Dim l m t i th n j pa)) where dimension _ = Dim' (toNum (Proxy :: Proxy l)) @@ -144,3 +167,4 @@ instance ( KnownTypeInt l (toNum (Proxy :: Proxy th)) (toNum (Proxy :: Proxy n)) (toNum (Proxy :: Proxy j)) + (toNum (Proxy :: Proxy pa)) diff --git a/src/Numeric/Units/Dimensional/DK/NonSI.hs b/src/Numeric/Units/Dimensional/DK/NonSI.hs index bd5c50e0..917576ff 100644 --- a/src/Numeric/Units/Dimensional/DK/NonSI.hs +++ b/src/Numeric/Units/Dimensional/DK/NonSI.hs @@ -142,9 +142,9 @@ mile = prefix 1760 yard nauticalMile = prefix 1852 meter knot :: (Fractional a) => Unit DVelocity a knot = nauticalMile / hour -revolution :: (Floating a) => Unit DOne a +revolution :: (Floating a) => Unit DPlaneAngle a revolution = prefix (2 Prelude.* Prelude.pi) radian -solid :: (Floating a) => Unit DOne a +solid :: (Floating a) => Unit DSolidAngle a solid = prefix (4 Prelude.* Prelude.pi) steradian teaspoon :: (Fractional a) => Unit DVolume a teaspoon = prefix 5 (milli liter) diff --git a/src/Numeric/Units/Dimensional/DK/Prelude.hs b/src/Numeric/Units/Dimensional/DK/Prelude.hs index d3e0b85f..390f5846 100644 --- a/src/Numeric/Units/Dimensional/DK/Prelude.hs +++ b/src/Numeric/Units/Dimensional/DK/Prelude.hs @@ -25,6 +25,7 @@ module Numeric.Units.Dimensional.DK.Prelude import Numeric.Units.Dimensional.DK hiding ( dmap + , removeAngles, coerceAngles ) import Numeric.Units.Dimensional.DK.Quantities diff --git a/src/Numeric/Units/Dimensional/DK/Quantities.hs b/src/Numeric/Units/Dimensional/DK/Quantities.hs index b4e5fe32..a4c3ce62 100644 --- a/src/Numeric/Units/Dimensional/DK/Quantities.hs +++ b/src/Numeric/Units/Dimensional/DK/Quantities.hs @@ -35,7 +35,7 @@ module Numeric.Units.Dimensional.DK.Quantities Area, Volume, Velocity, Acceleration, WaveNumber, MassDensity, Density, SpecificVolume, CurrentDensity, MagneticFieldStrength, AmountOfSubstanceConcentration, Concentration, Luminance, -- $table3 - PlaneAngle, SolidAngle, Frequency, Force, Pressure, Stress, Energy, Work, QuantityOfHeat, Power, RadiantFlux, + Frequency, Force, Pressure, Stress, Energy, Work, QuantityOfHeat, Power, RadiantFlux, ElectricCharge, QuantityOfElectricity, ElectricPotential, PotentialDifference, ElectromotiveForce, Capacitance, ElectricResistance, ElectricConductance, MagneticFlux, MagneticFluxDensity, Inductance, LuminousFlux, Illuminance, CelsiusTemperature, @@ -49,7 +49,7 @@ module Numeric.Units.Dimensional.DK.Quantities -- $not-nist-guide Impulse, Momentum, MassFlow, VolumeFlow, GravitationalParameter, KinematicViscosity, FirstMassMoment, MomentOfInertia, AngularMomentum, ThermalResistivity, ThermalConductance, ThermalResistance, HeatTransferCoefficient, ThermalAdmittance, ThermalInsulance, - Jerk, Angle, Thrust, Torque, EnergyPerUnitMass, + Jerk, Angle, Thrust, Torque, EnergyPerUnitMass, SolidAngle, -- * Powers of Unit Lengths -- $powers-of-length-units square, cubic, @@ -57,7 +57,7 @@ module Numeric.Units.Dimensional.DK.Quantities -- $dimension-aliases DArea, DVolume, DVelocity, DAcceleration, DWaveNumber, DMassDensity, DDensity, DSpecificVolume, DCurrentDensity, DMagneticFieldStrength, DAmountOfSubstanceConcentration, DConcentration, DLuminance, - DPlaneAngle, DSolidAngle, DFrequency, DForce, DPressure, DStress, DEnergy, DWork, DQuantityOfHeat, DPower, DRadiantFlux, + DFrequency, DForce, DPressure, DStress, DEnergy, DWork, DQuantityOfHeat, DPower, DRadiantFlux, DElectricCharge, DQuantityOfElectricity, DElectricPotential, DPotentialDifference, DElectromotiveForce, DCapacitance, DElectricResistance, DElectricConductance, DMagneticFlux, DMagneticFluxDensity, DInductance, DLuminousFlux, DIlluminance, DCelsiusTemperature, @@ -68,13 +68,13 @@ module Numeric.Units.Dimensional.DK.Quantities DMolarEnergy, DMolarEntropy, DMolarHeatCapacity, DExposure, DAbsorbedDoseRate, DImpulse, DMomentum, DMassFlow, DVolumeFlow, DGravitationalParameter, DKinematicViscosity, DFirstMassMoment, DMomentOfInertia, DAngularMomentum, DThermalResistivity, DThermalConductance, DThermalResistance, DHeatTransferCoefficient, DThermalAdmittance, DThermalInsulance, - DJerk, DAngle, DThrust, DTorque, DEnergyPerUnitMass + DJerk, DAngle, DThrust, DTorque, DEnergyPerUnitMass, DSolidAngle ) where import Numeric.Units.Dimensional.DK - ( Dimension (Dim), Quantity, Dimensionless - , DOne, DLuminousIntensity, DThermodynamicTemperature + ( Dimension (Dim), Quantity + , DThermodynamicTemperature, DPlaneAngle , Unit, DLength, (^) -- Used only for 'square' and 'cubic'. ) import Numeric.NumType.DK.Integers @@ -104,41 +104,41 @@ For each 'Quantity' alias supplied above, we also supply a corresponding 'Dimens These dimension aliases may be convenient for supplying type signatures for 'Unit's or for other type-level dimensional programming. -} -type DArea = 'Dim 'Pos2 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero +type DArea = 'Dim 'Pos2 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero type Area = Quantity DArea -type DVolume = 'Dim 'Pos3 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero +type DVolume = 'Dim 'Pos3 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero type Volume = Quantity DVolume -type DVelocity = 'Dim 'Pos1 'Zero 'Neg1 'Zero 'Zero 'Zero 'Zero +type DVelocity = 'Dim 'Pos1 'Zero 'Neg1 'Zero 'Zero 'Zero 'Zero 'Zero type Velocity = Quantity DVelocity -type DAcceleration = 'Dim 'Pos1 'Zero 'Neg2 'Zero 'Zero 'Zero 'Zero +type DAcceleration = 'Dim 'Pos1 'Zero 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero type Acceleration = Quantity DAcceleration -type DWaveNumber = 'Dim 'Neg1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero +type DWaveNumber = 'Dim 'Neg1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero type WaveNumber = Quantity DWaveNumber -type DMassDensity = 'Dim 'Neg3 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero +type DMassDensity = 'Dim 'Neg3 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero type DDensity = DMassDensity type MassDensity = Quantity DMassDensity type Density = MassDensity -- Short name. -type DSpecificVolume = 'Dim 'Pos3 'Neg1 'Zero 'Zero 'Zero 'Zero 'Zero +type DSpecificVolume = 'Dim 'Pos3 'Neg1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero type SpecificVolume = Quantity DSpecificVolume -type DCurrentDensity = 'Dim 'Neg2 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero +type DCurrentDensity = 'Dim 'Neg2 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero type CurrentDensity = Quantity DCurrentDensity -type DMagneticFieldStrength = 'Dim 'Neg1 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero +type DMagneticFieldStrength = 'Dim 'Neg1 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero type MagneticFieldStrength = Quantity DMagneticFieldStrength -type DAmountOfSubstanceConcentration = 'Dim 'Neg3 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero +type DAmountOfSubstanceConcentration = 'Dim 'Neg3 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero 'Zero type DConcentration = DAmountOfSubstanceConcentration type AmountOfSubstanceConcentration = Quantity DAmountOfSubstanceConcentration type Concentration = AmountOfSubstanceConcentration -- Short name. -type DLuminance = 'Dim 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 +type DLuminance = 'Dim 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero type Luminance = Quantity DLuminance @@ -149,69 +149,63 @@ SI coherent derived units with special names and symbols. -} -type DPlaneAngle = DOne -type PlaneAngle = Dimensionless - -type DSolidAngle = DOne -type SolidAngle = Dimensionless - -type DFrequency = 'Dim 'Zero 'Zero 'Neg1 'Zero 'Zero 'Zero 'Zero +type DFrequency = 'Dim 'Zero 'Zero 'Neg1 'Zero 'Zero 'Zero 'Zero 'Zero type Frequency = Quantity DFrequency -type DForce = 'Dim 'Pos1 'Pos1 'Neg2 'Zero 'Zero 'Zero 'Zero +type DForce = 'Dim 'Pos1 'Pos1 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero type Force = Quantity DForce -type DPressure = 'Dim 'Neg1 'Pos1 'Neg2 'Zero 'Zero 'Zero 'Zero +type DPressure = 'Dim 'Neg1 'Pos1 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero type DStress = DPressure type Pressure = Quantity DPressure type Stress = Quantity DStress -type DEnergy = 'Dim 'Pos2 'Pos1 'Neg2 'Zero 'Zero 'Zero 'Zero +type DEnergy = 'Dim 'Pos2 'Pos1 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero type DWork = DEnergy type DQuantityOfHeat = DEnergy type Energy = Quantity DEnergy type Work = Quantity DWork type QuantityOfHeat = Quantity DQuantityOfHeat -type DPower = 'Dim 'Pos2 'Pos1 'Neg3 'Zero 'Zero 'Zero 'Zero +type DPower = 'Dim 'Pos2 'Pos1 'Neg3 'Zero 'Zero 'Zero 'Zero 'Zero type DRadiantFlux = DPower type Power = Quantity DPower type RadiantFlux = Quantity DRadiantFlux -type DElectricCharge = 'Dim 'Zero 'Zero 'Pos1 'Pos1 'Zero 'Zero 'Zero +type DElectricCharge = 'Dim 'Zero 'Zero 'Pos1 'Pos1 'Zero 'Zero 'Zero 'Zero type DQuantityOfElectricity = DElectricCharge type ElectricCharge = Quantity DElectricCharge type QuantityOfElectricity = Quantity DQuantityOfElectricity -type DElectricPotential = 'Dim 'Pos2 'Pos1 'Neg3 'Neg1 'Zero 'Zero 'Zero +type DElectricPotential = 'Dim 'Pos2 'Pos1 'Neg3 'Neg1 'Zero 'Zero 'Zero 'Zero type DPotentialDifference = DElectricPotential type DElectromotiveForce = DElectricPotential type ElectricPotential = Quantity DElectricPotential type PotentialDifference = Quantity DPotentialDifference type ElectromotiveForce = Quantity DElectromotiveForce -type DCapacitance = 'Dim 'Neg2 'Neg1 'Pos4 'Pos2 'Zero 'Zero 'Zero +type DCapacitance = 'Dim 'Neg2 'Neg1 'Pos4 'Pos2 'Zero 'Zero 'Zero 'Zero type Capacitance = Quantity DCapacitance -type DElectricResistance = 'Dim 'Pos2 'Pos1 'Neg3 'Neg2 'Zero 'Zero 'Zero +type DElectricResistance = 'Dim 'Pos2 'Pos1 'Neg3 'Neg2 'Zero 'Zero 'Zero 'Zero type ElectricResistance = Quantity DElectricResistance -type DElectricConductance = 'Dim 'Neg2 'Neg1 'Pos3 'Pos2 'Zero 'Zero 'Zero +type DElectricConductance = 'Dim 'Neg2 'Neg1 'Pos3 'Pos2 'Zero 'Zero 'Zero 'Zero type ElectricConductance = Quantity DElectricConductance -type DMagneticFlux = 'Dim 'Pos2 'Pos1 'Neg2 'Neg1 'Zero 'Zero 'Zero +type DMagneticFlux = 'Dim 'Pos2 'Pos1 'Neg2 'Neg1 'Zero 'Zero 'Zero 'Zero type MagneticFlux = Quantity DMagneticFlux -type DMagneticFluxDensity = 'Dim 'Zero 'Pos1 'Neg2 'Neg1 'Zero 'Zero 'Zero +type DMagneticFluxDensity = 'Dim 'Zero 'Pos1 'Neg2 'Neg1 'Zero 'Zero 'Zero 'Zero type MagneticFluxDensity = Quantity DMagneticFluxDensity -type DInductance = 'Dim 'Pos2 'Pos1 'Neg2 'Neg2 'Zero 'Zero 'Zero +type DInductance = 'Dim 'Pos2 'Pos1 'Neg2 'Neg2 'Zero 'Zero 'Zero 'Zero type Inductance = Quantity DInductance -type DLuminousFlux = DLuminousIntensity +type DLuminousFlux = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Pos2 type LuminousFlux = Quantity DLuminousFlux -type DIlluminance = 'Dim 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 +type DIlluminance = 'Dim 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Pos2 type Illuminance = Quantity DIlluminance type DCelsiusTemperature = DThermodynamicTemperature @@ -220,7 +214,7 @@ type CelsiusTemperature = Quantity DCelsiusTemperature type DActivity = DFrequency -- Activity of a radionuclide. type Activity = Quantity DActivity -type DAbsorbedDose = 'Dim 'Pos2 'Zero 'Neg2 'Zero 'Zero 'Zero 'Zero +type DAbsorbedDose = 'Dim 'Pos2 'Zero 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero type DSpecificEnergy = DAbsorbedDose type DKerma = DAbsorbedDose type AbsorbedDose = Quantity DAbsorbedDose @@ -238,7 +232,7 @@ type DirectionalDoseEquivalent = DoseEquivalent type PersonalDoseEquivalent = DoseEquivalent type EquivalentDose = DoseEquivalent -type DCatalyticActivity = 'Dim 'Zero 'Zero 'Neg1 'Zero 'Zero 'Pos1 'Zero +type DCatalyticActivity = 'Dim 'Zero 'Zero 'Neg1 'Zero 'Zero 'Pos1 'Zero 'Zero type CatalyticActivity = Quantity DCatalyticActivity {- $table4 @@ -251,38 +245,38 @@ We use the same grouping as for table 2. -} -type DAngularVelocity = DFrequency +type DAngularVelocity = 'Dim 'Zero 'Zero 'Neg1 'Zero 'Zero 'Zero 'Zero 'Pos1 type AngularVelocity = Quantity DAngularVelocity -type DAngularAcceleration = 'Dim 'Zero 'Zero 'Neg2 'Zero 'Zero 'Zero 'Zero +type DAngularAcceleration = 'Dim 'Zero 'Zero 'Neg2 'Zero 'Zero 'Zero 'Zero 'Pos1 type AngularAcceleration = Quantity DAngularAcceleration -type DDynamicViscosity = 'Dim 'Neg1 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero +type DDynamicViscosity = 'Dim 'Neg1 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero 'Zero type DynamicViscosity = Quantity DDynamicViscosity type DMomentOfForce = DEnergy type MomentOfForce = Quantity DMomentOfForce -type DSurfaceTension = 'Dim 'Zero 'Pos1 'Neg2 'Zero 'Zero 'Zero 'Zero +type DSurfaceTension = 'Dim 'Zero 'Pos1 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero type SurfaceTension = Quantity DSurfaceTension -type DHeatFluxDensity = 'Dim 'Zero 'Pos1 'Neg3 'Zero 'Zero 'Zero 'Zero +type DHeatFluxDensity = 'Dim 'Zero 'Pos1 'Neg3 'Zero 'Zero 'Zero 'Zero 'Zero type DIrradiance = DHeatFluxDensity type HeatFluxDensity = Quantity DHeatFluxDensity type Irradiance = Quantity DIrradiance -type DRadiantIntensity = DPower +type DRadiantIntensity = 'Dim 'Pos2 'Pos1 'Neg3 'Zero 'Zero 'Zero 'Zero 'Neg2 type RadiantIntensity = Quantity DRadiantIntensity -type DRadiance = DIrradiance +type DRadiance = 'Dim 'Zero 'Pos1 'Neg3 'Zero 'Zero 'Zero 'Zero 'Neg2 type Radiance = Quantity DRadiance -type DHeatCapacity = 'Dim 'Pos2 'Pos1 'Neg2 'Zero 'Neg1 'Zero 'Zero +type DHeatCapacity = 'Dim 'Pos2 'Pos1 'Neg2 'Zero 'Neg1 'Zero 'Zero 'Zero type DEntropy = DHeatCapacity type HeatCapacity = Quantity DHeatCapacity type Entropy = Quantity DEntropy -type DSpecificHeatCapacity = 'Dim 'Pos2 'Zero 'Neg2 'Zero 'Neg1 'Zero 'Zero +type DSpecificHeatCapacity = 'Dim 'Pos2 'Zero 'Neg2 'Zero 'Neg1 'Zero 'Zero 'Zero type DSpecificEntropy = DSpecificHeatCapacity type SpecificHeatCapacity = Quantity DSpecificHeatCapacity type SpecificEntropy = Quantity DSpecificEntropy @@ -293,39 +287,39 @@ Specific energy was already defined in table 3. -} -type DThermalConductivity = 'Dim 'Pos1 'Pos1 'Neg3 'Zero 'Neg1 'Zero 'Zero +type DThermalConductivity = 'Dim 'Pos1 'Pos1 'Neg3 'Zero 'Neg1 'Zero 'Zero 'Zero type ThermalConductivity = Quantity DThermalConductivity type DEnergyDensity = DPressure type EnergyDensity = Quantity DEnergyDensity -type DElectricFieldStrength = 'Dim 'Pos1 'Pos1 'Neg3 'Neg1 'Zero 'Zero 'Zero +type DElectricFieldStrength = 'Dim 'Pos1 'Pos1 'Neg3 'Neg1 'Zero 'Zero 'Zero 'Zero type ElectricFieldStrength = Quantity DElectricFieldStrength -type DElectricChargeDensity = 'Dim 'Neg3 'Zero 'Pos1 'Pos1 'Zero 'Zero 'Zero +type DElectricChargeDensity = 'Dim 'Neg3 'Zero 'Pos1 'Pos1 'Zero 'Zero 'Zero 'Zero type ElectricChargeDensity = Quantity DElectricChargeDensity -type DElectricFluxDensity = 'Dim 'Neg2 'Zero 'Pos1 'Pos1 'Zero 'Zero 'Zero +type DElectricFluxDensity = 'Dim 'Neg2 'Zero 'Pos1 'Pos1 'Zero 'Zero 'Zero 'Zero type ElectricFluxDensity = Quantity DElectricFluxDensity -type DPermittivity = 'Dim 'Neg3 'Neg1 'Pos4 'Pos2 'Zero 'Zero 'Zero +type DPermittivity = 'Dim 'Neg3 'Neg1 'Pos4 'Pos2 'Zero 'Zero 'Zero 'Zero type Permittivity = Quantity DPermittivity -type DPermeability = 'Dim 'Pos1 'Pos1 'Neg2 'Neg2 'Zero 'Zero 'Zero +type DPermeability = 'Dim 'Pos1 'Pos1 'Neg2 'Neg2 'Zero 'Zero 'Zero 'Zero type Permeability = Quantity DPermeability -type DMolarEnergy = 'Dim 'Pos2 'Pos1 'Neg2 'Zero 'Zero 'Neg1 'Zero +type DMolarEnergy = 'Dim 'Pos2 'Pos1 'Neg2 'Zero 'Zero 'Neg1 'Zero 'Zero type MolarEnergy = Quantity DMolarEnergy -type DMolarEntropy = 'Dim 'Pos2 'Pos1 'Neg2 'Zero 'Neg1 'Neg1 'Zero +type DMolarEntropy = 'Dim 'Pos2 'Pos1 'Neg2 'Zero 'Neg1 'Neg1 'Zero 'Zero type DMolarHeatCapacity = DMolarEntropy type MolarEntropy = Quantity DMolarEntropy type MolarHeatCapacity = Quantity DMolarHeatCapacity -type DExposure = 'Dim 'Zero 'Neg1 'Pos1 'Pos1 'Zero 'Zero 'Zero +type DExposure = 'Dim 'Zero 'Neg1 'Pos1 'Pos1 'Zero 'Zero 'Zero 'Zero type Exposure = Quantity DExposure -- Exposure to x and gamma rays. -type DAbsorbedDoseRate = 'Dim 'Pos2 'Zero 'Neg3 'Zero 'Zero 'Zero 'Zero +type DAbsorbedDoseRate = 'Dim 'Pos2 'Zero 'Neg3 'Zero 'Zero 'Zero 'Zero 'Zero type AbsorbedDoseRate = Quantity DAbsorbedDoseRate {- $not-nist-guide @@ -333,31 +327,31 @@ Here we define additional quantities on an as-needed basis. We also provide some synonyms that we anticipate will be useful. -} -type DImpulse = 'Dim 'Pos1 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero +type DImpulse = 'Dim 'Pos1 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero 'Zero type Impulse = Quantity DImpulse type DMomentum = DImpulse type Momentum = Quantity DMomentum -type DMassFlow = 'Dim 'Zero 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero +type DMassFlow = 'Dim 'Zero 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero 'Zero type MassFlow = Quantity DMassFlow -type DVolumeFlow = 'Dim 'Pos3 'Zero 'Neg1 'Zero 'Zero 'Zero 'Zero +type DVolumeFlow = 'Dim 'Pos3 'Zero 'Neg1 'Zero 'Zero 'Zero 'Zero 'Zero type VolumeFlow = Quantity DVolumeFlow -type DGravitationalParameter = 'Dim 'Pos3 'Zero 'Neg2 'Zero 'Zero 'Zero 'Zero +type DGravitationalParameter = 'Dim 'Pos3 'Zero 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero type GravitationalParameter = Quantity DGravitationalParameter -type DKinematicViscosity = 'Dim 'Pos2 'Zero 'Neg1 'Zero 'Zero 'Zero 'Zero +type DKinematicViscosity = 'Dim 'Pos2 'Zero 'Neg1 'Zero 'Zero 'Zero 'Zero 'Zero type KinematicViscosity = Quantity DKinematicViscosity -type DFirstMassMoment = 'Dim 'Pos1 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero +type DFirstMassMoment = 'Dim 'Pos1 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero type FirstMassMoment = Quantity DFirstMassMoment -type DMomentOfInertia = 'Dim 'Pos2 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero +type DMomentOfInertia = 'Dim 'Pos2 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Neg2 type MomentOfInertia = Quantity DMomentOfInertia -type DAngularMomentum = 'Dim 'Pos2 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero +type DAngularMomentum = 'Dim 'Pos2 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero 'Neg1 type AngularMomentum = Quantity DAngularMomentum {- @@ -366,7 +360,7 @@ The reciprocal of thermal conductivity. -} -type DThermalResistivity = 'Dim 'Neg1 'Neg1 'Pos3 'Zero 'Pos1 'Zero 'Zero +type DThermalResistivity = 'Dim 'Neg1 'Neg1 'Pos3 'Zero 'Pos1 'Zero 'Zero 'Zero type ThermalResistivity = Quantity DThermalResistivity {- @@ -375,35 +369,38 @@ Thermal conductance and resistance quantities after http://en.wikipedia.org/wiki -} -type DThermalConductance = 'Dim 'Pos2 'Pos1 'Neg3 'Zero 'Neg1 'Zero 'Zero +type DThermalConductance = 'Dim 'Pos2 'Pos1 'Neg3 'Zero 'Neg1 'Zero 'Zero 'Zero type ThermalConductance = Quantity DThermalConductance -type DThermalResistance = 'Dim 'Neg2 'Neg1 'Pos3 'Zero 'Pos1 'Zero 'Zero +type DThermalResistance = 'Dim 'Neg2 'Neg1 'Pos3 'Zero 'Pos1 'Zero 'Zero 'Zero type ThermalResistance = Quantity DThermalResistance -type DHeatTransferCoefficient = 'Dim 'Zero 'Pos1 'Neg3 'Zero 'Neg1 'Zero 'Zero +type DHeatTransferCoefficient = 'Dim 'Zero 'Pos1 'Neg3 'Zero 'Neg1 'Zero 'Zero 'Zero type HeatTransferCoefficient = Quantity DHeatTransferCoefficient type DThermalAdmittance = DHeatTransferCoefficient type ThermalAdmittance = HeatTransferCoefficient -type DThermalInsulance = 'Dim 'Zero 'Neg1 'Pos3 'Zero 'Pos1 'Zero 'Zero +type DThermalInsulance = 'Dim 'Zero 'Neg1 'Pos3 'Zero 'Pos1 'Zero 'Zero 'Zero type ThermalInsulance = Quantity DThermalInsulance -type DJerk = 'Dim 'Pos1 'Zero 'Neg3 'Zero 'Zero 'Zero 'Zero +type DJerk = 'Dim 'Pos1 'Zero 'Neg3 'Zero 'Zero 'Zero 'Zero 'Zero type Jerk = Quantity DJerk -type Angle = PlaneAngle -- Abbreviation type DAngle = DPlaneAngle -- Abbreviation +type Angle = Quantity DAngle -- Abbreviation -type Thrust = Force type DThrust = DForce +type Thrust = Force -type Torque = MomentOfForce -type DTorque = DMomentOfForce +type DTorque = 'Dim 'Pos2 'Pos1 'Neg2 'Zero 'Zero 'Zero 'Zero 'Neg1 +type Torque = Quantity DTorque -type EnergyPerUnitMass = SpecificEnergy type DEnergyPerUnitMass = DSpecificEnergy +type EnergyPerUnitMass = SpecificEnergy + +type DSolidAngle = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos2 +type SolidAngle = Quantity DSolidAngle {- $powers-of-length-units It is permissible to express powers of length units by prefixing diff --git a/src/Numeric/Units/Dimensional/DK/SI.hs b/src/Numeric/Units/Dimensional/DK/SI.hs new file mode 100644 index 00000000..81ee4af6 --- /dev/null +++ b/src/Numeric/Units/Dimensional/DK/SI.hs @@ -0,0 +1,48 @@ +{-# LANGUAGE DataKinds #-} + +{- | + Copyright : Copyright (C) 2006-2015 Bjorn Buckwalter + License : BSD3 + + Maintainer : bjorn@buckwalter.se + Stability : Stable + Portability: GHC only + += Summary + +This module defines a variant of "Numeric.Units.Dimensional.DK" where plane angles are treated as dimensionless. + +Compare, e.g., 'sin' with 'Numeric.Units.Dimensional.DK.sin' + +-} +module Numeric.Units.Dimensional.DK.SI +( + module Numeric.Units.Dimensional.DK, + sin, cos, tan, asin, acos, atan, atan2, + DPlaneAngle, + PlaneAngle, + baseUnit +) +where + +import qualified Numeric.Units.Dimensional.DK as A +import Numeric.Units.Dimensional.DK hiding (sin, cos, tan, asin, acos, atan, atan2, DPlaneAngle, PlaneAngle, baseUnit) +import Prelude hiding (sin, cos, tan, asin, acos, atan, atan2) + +sin, cos, tan, asin, acos, atan :: (Floating a) => Dimensionless a -> Dimensionless a +sin = A.sin . coerceAngles +cos = A.cos . coerceAngles +tan = A.tan . coerceAngles +asin = removeAngles . A.asin +acos = removeAngles . A.acos +atan = removeAngles . A.atan + +atan2 :: (RealFloat a) => Quantity d a -> Quantity d a -> Dimensionless a +atan2 x y = removeAngles $ A.atan2 x y + +type DPlaneAngle = DOne + +type PlaneAngle = Quantity DPlaneAngle + +baseUnit :: (Num a) => Unit (SIDim l m t i th n j) a +baseUnit = siUnit diff --git a/src/Numeric/Units/Dimensional/DK/SI/Prelude.hs b/src/Numeric/Units/Dimensional/DK/SI/Prelude.hs new file mode 100644 index 00000000..17dbc7ab --- /dev/null +++ b/src/Numeric/Units/Dimensional/DK/SI/Prelude.hs @@ -0,0 +1,45 @@ +{- | + Copyright : Copyright (C) 2006-2015 Bjorn Buckwalter + License : BSD3 + + Maintainer : bjorn@buckwalter.se + Stability : Stable + Portability: GHC only + += Summary + +This module defines a variant of "Numeric.Units.Dimensional.DK.Prelude" where plane angles are treated as dimensionless. + +-} +module Numeric.Units.Dimensional.DK.SI.Prelude + ( module Numeric.Units.Dimensional.DK.SI + , module Numeric.Units.Dimensional.DK.SI.Quantities + , module Numeric.Units.Dimensional.DK.SI.SIUnits + , module Numeric.NumType.DK.Integers + , module Data.Foldable + , module Prelude + ) where + +import Numeric.Units.Dimensional.DK.SI hiding + ( dmap + ) + +import Numeric.Units.Dimensional.DK.SI.Quantities + +import Numeric.Units.Dimensional.DK.SI.SIUnits + +import Numeric.NumType.DK.Integers + ( neg5, neg4, neg3, neg2, neg1, zero, pos1, pos2, pos3, pos4, pos5 + ) -- Used in exponents. + +import Data.Foldable + ( product, minimum, maximum ) + +import Prelude hiding + ( (+), (-), (*), (/), (^), (**) + , abs, negate, pi, exp, log, sqrt + , sin, cos, tan, asin, acos, atan, atan2 + , sinh, cosh, tanh, asinh, acosh, atanh + , sum, product, minimum, maximum + ) -- Hide definitions overridden by 'Numeric.Dimensional'. + \ No newline at end of file diff --git a/src/Numeric/Units/Dimensional/DK/SI/Quantities.hs b/src/Numeric/Units/Dimensional/DK/SI/Quantities.hs new file mode 100644 index 00000000..317d11f4 --- /dev/null +++ b/src/Numeric/Units/Dimensional/DK/SI/Quantities.hs @@ -0,0 +1,62 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE TypeFamilies #-} + +{- | + Copyright : Copyright (C) 2006-2015 Bjorn Buckwalter + License : BSD3 + + Maintainer : bjorn@buckwalter.se + Stability : Stable + Portability: GHC only + += Summary + +This module defines a variant of "Numeric.Units.Dimensional.DK.Quantities" where plane angles are treated as dimensionless. + +Compare, e.g., 'LuminousFlux' with 'Numeric.Units.Dimensional.DK.Quantities.LuminousFlux' + +-} +module Numeric.Units.Dimensional.DK.SI.Quantities +( + module Numeric.Units.Dimensional.DK.Quantities, + + LuminousFlux, Illuminance, AngularVelocity, AngularAcceleration, RadiantIntensity, Radiance, AngularMomentum, Torque, MomentOfInertia, SolidAngle, + DLuminousFlux, DIlluminance, DAngularVelocity, DAngularAcceleration, DRadiantIntensity, DRadiance, DAngularMomentum, DTorque, DMomentOfInertia, DSolidAngle +) +where + +import Numeric.Units.Dimensional.DK.SI +import qualified Numeric.Units.Dimensional.DK.Quantities as A +import Numeric.Units.Dimensional.DK.Quantities hiding (LuminousFlux, Illuminance, AngularVelocity, AngularAcceleration, RadiantIntensity, Radiance, AngularMomentum, Torque, MomentOfInertia, SolidAngle, + DLuminousFlux, DIlluminance, DAngularVelocity, DAngularAcceleration, DRadiantIntensity, DRadiance, DAngularMomentum, DTorque, DMomentOfInertia, DSolidAngle) + +type DLuminousFlux = ToSIDim A.DLuminousFlux +type LuminousFlux = Quantity DLuminousFlux + +type DIlluminance = ToSIDim A.DIlluminance +type Illuminance = Quantity DIlluminance + +type DAngularVelocity = ToSIDim A.DAngularVelocity +type AngularVelocity = Quantity DAngularVelocity + +type DAngularAcceleration = ToSIDim A.DAngularAcceleration +type AngularAcceleration = Quantity DAngularAcceleration + +type DRadiantIntensity = ToSIDim A.DRadiantIntensity +type RadiantIntensity = Quantity DRadiantIntensity + +type DRadiance = ToSIDim A.DRadiance +type Radiance = Quantity DRadiance + +type DAngularMomentum = ToSIDim A.DAngularMomentum +type AngularMomentum = Quantity DAngularMomentum + +type DTorque = ToSIDim A.DTorque +type Torque = Quantity DTorque + +type DMomentOfInertia = ToSIDim A.DMomentOfInertia +type MomentOfInertia = Quantity DMomentOfInertia + +type DSolidAngle = ToSIDim A.DSolidAngle +type SolidAngle = Quantity DSolidAngle diff --git a/src/Numeric/Units/Dimensional/DK/SI/SIUnits.hs b/src/Numeric/Units/Dimensional/DK/SI/SIUnits.hs new file mode 100644 index 00000000..7e5ac22f --- /dev/null +++ b/src/Numeric/Units/Dimensional/DK/SI/SIUnits.hs @@ -0,0 +1,45 @@ +{- | + Copyright : Copyright (C) 2006-2015 Bjorn Buckwalter + License : BSD3 + + Maintainer : bjorn@buckwalter.se + Stability : Stable + Portability: GHC only + += Summary + +This module defines a variant of "Numeric.Units.Dimensional.DK.SIUnits" where plane angles are treated as dimensionless. + +Compare, e.g., 'radian' with 'Numeric.Units.Dimensional.DK.SIUnits.radian' + +-} +module Numeric.Units.Dimensional.DK.SI.SIUnits +( + module Numeric.Units.Dimensional.DK.SIUnits, + radian, steradian, + degree, arcminute, arcsecond, degreeOfArc, minuteOfArc, secondOfArc, + lumen, lux +) +where + +import Numeric.Units.Dimensional.DK.SI +import Numeric.Units.Dimensional.DK.SI.Quantities +import qualified Numeric.Units.Dimensional.DK.SIUnits as A +import Numeric.Units.Dimensional.DK.SIUnits hiding (radian, steradian, degree, arcminute, arcsecond, degreeOfArc, minuteOfArc, secondOfArc, lumen, lux) + +radian, steradian :: (Num a) => Unit DPlaneAngle a +radian = removeAngles A.radian +steradian = removeAngles A.steradian + +degree, arcminute, arcsecond, degreeOfArc, minuteOfArc, secondOfArc :: (Floating a) => Unit DPlaneAngle a +degree = removeAngles A.degree +arcminute = removeAngles A.arcminute +arcsecond = removeAngles A.arcsecond +degreeOfArc = removeAngles A.degreeOfArc +minuteOfArc = removeAngles A.minuteOfArc +secondOfArc = removeAngles A.secondOfArc + +lumen :: Num a => Unit DLuminousFlux a +lumen = removeAngles A.lumen +lux :: Num a => Unit DIlluminance a +lux = removeAngles A.lux diff --git a/src/Numeric/Units/Dimensional/DK/SIUnits.hs b/src/Numeric/Units/Dimensional/DK/SIUnits.hs index 25cc5083..351a69f8 100644 --- a/src/Numeric/Units/Dimensional/DK/SIUnits.hs +++ b/src/Numeric/Units/Dimensional/DK/SIUnits.hs @@ -118,7 +118,7 @@ We define the SI base units in the order of table 1. -} metre, meter :: Num a => Unit DLength a -metre = siUnit -- International English. +metre = baseUnit -- International English. meter = metre -- American English. {- @@ -130,17 +130,17 @@ The drawback is that we are forced to use 'Fractional'. -} gram :: Fractional a => Unit DMass a -gram = milli siUnit +gram = milli baseUnit second :: Num a => Unit DTime a -second = siUnit +second = baseUnit ampere :: Num a => Unit DElectricCurrent a -ampere = siUnit +ampere = baseUnit kelvin :: Num a => Unit DThermodynamicTemperature a -kelvin = siUnit +kelvin = baseUnit mole :: Num a => Unit DAmountOfSubstance a -mole = siUnit +mole = baseUnit candela :: Num a => Unit DLuminousIntensity a -candela = siUnit +candela = baseUnit {- $derived-units From Table 3, SI derived units with special names and symbols, including the @@ -148,9 +148,9 @@ radian and steradian. -} radian :: Num a => Unit DPlaneAngle a -radian = one -- meter * meter ^ neg1 +radian = baseUnit -- meter * meter ^ neg1 steradian :: Num a => Unit DSolidAngle a -steradian = one -- meter ^ pos2 * meter ^ neg2 +steradian = baseUnit -- meter ^ pos2 * meter ^ neg2 hertz :: Num a => Unit DFrequency a hertz = siUnit -- second ^ neg1 newton :: Num a => Unit DForce a @@ -184,9 +184,9 @@ appear here if we stricly followed table 3). -} lumen :: Num a => Unit DLuminousFlux a -lumen = siUnit -- candela * steradian +lumen = baseUnit -- candela * steradian lux :: Num a => Unit DIlluminance a -lux = siUnit -- lumen / meter ^ pos2 +lux = baseUnit -- lumen / meter ^ pos2 {- $celsius A problematic area is units which increase proportionally to the diff --git a/tests/Numeric/Units/Dimensional/DK/QuantitiesTest.hs b/tests/Numeric/Units/Dimensional/DK/QuantitiesTest.hs index 68a4a7b6..c6313f63 100644 --- a/tests/Numeric/Units/Dimensional/DK/QuantitiesTest.hs +++ b/tests/Numeric/Units/Dimensional/DK/QuantitiesTest.hs @@ -1,6 +1,7 @@ module Numeric.Units.Dimensional.DK.QuantitiesTest where import Numeric.Units.Dimensional.DK.Prelude +import Numeric.Units.Dimensional.DK import qualified Prelude -- These definitions simply verify that the type synonyms are @@ -35,9 +36,9 @@ x11 = 1 *~ (candela / meter ^ pos2) -- definitions compile the type synonyms are good. y1 :: PlaneAngle Double -y1 = 1 *~ (meter / meter) +y1 = coerceAngles $ 1 *~ (meter / meter) y2 :: SolidAngle Double -y2 = 1 *~ (meter ^ pos2 / meter ^ pos2) +y2 = coerceAngles $ 1 *~ (meter ^ pos2 / meter ^ pos2) y3 :: Frequency Double y3 = 1 *~ (one / second) y4 :: Force Double