From 7bd85bc2977af8cbe8b67fc995534afa7c79da57 Mon Sep 17 00:00:00 2001 From: Douglas McClean Date: Wed, 15 Jul 2015 19:21:49 -0400 Subject: [PATCH 01/12] Added plane and solid angles as base dimensions. --- src/Numeric/Units/Dimensional/DK.hs | 24 +-- .../Dimensional/DK/Dimensions/TermLevel.hs | 45 +++--- .../Dimensional/DK/Dimensions/TypeLevel.hs | 49 +++--- src/Numeric/Units/Dimensional/DK/NonSI.hs | 4 +- .../Units/Dimensional/DK/Quantities.hs | 144 +++++++++--------- src/Numeric/Units/Dimensional/DK/SIUnits.hs | 4 +- 6 files changed, 141 insertions(+), 129 deletions(-) diff --git a/src/Numeric/Units/Dimensional/DK.hs b/src/Numeric/Units/Dimensional/DK.hs index 303a0f55..b558c0d5 100644 --- a/src/Numeric/Units/Dimensional/DK.hs +++ b/src/Numeric/Units/Dimensional/DK.hs @@ -210,10 +210,10 @@ module Numeric.Units.Dimensional.DK (*~~), (/~~), 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, DSolidAngle, -- * Quantity Synonyms -- $quantity-synonyms - Dimensionless, Length, Mass, Time, ElectricCurrent, ThermodynamicTemperature, AmountOfSubstance, LuminousIntensity, + Dimensionless, Length, Mass, Time, ElectricCurrent, ThermodynamicTemperature, AmountOfSubstance, LuminousIntensity, PlaneAngle, SolidAngle, -- * Constants -- $constants _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, pi, tau, @@ -372,6 +372,8 @@ type ElectricCurrent = Quantity DElectricCurrent type ThermodynamicTemperature = Quantity DThermodynamicTemperature type AmountOfSubstance = Quantity DAmountOfSubstance type LuminousIntensity = Quantity DLuminousIntensity +type PlaneAngle = Quantity DPlaneAngle +type SolidAngle = Quantity DSolidAngle {- $dimension-arithmetic When performing arithmetic on units and quantities the arithmetics @@ -568,16 +570,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 @@ -585,6 +581,16 @@ 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 . (/~ siUnit) +cos = (*~ one) . Prelude.cos . (/~ siUnit) +tan = (*~ one) . Prelude.tan . (/~ siUnit) + +asin, acos, atan :: Floating a => Dimensionless a -> PlaneAngle a +asin = (*~ siUnit) . Prelude.asin . (/~ one) +acos = (*~ siUnit) . Prelude.acos . (/~ one) +atan = (*~ siUnit) . Prelude.atan . (/~ one) + (**) :: Floating a => Dimensionless a -> Dimensionless a -> Dimensionless a Dimensional x ** Dimensional y = Dimensional (x Prelude.** y) diff --git a/src/Numeric/Units/Dimensional/DK/Dimensions/TermLevel.hs b/src/Numeric/Units/Dimensional/DK/Dimensions/TermLevel.hs index 2cf7e968..9608ebea 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 and solid 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, dSolidAngle, -- * 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 9 integers, representing a factorization of the dimension into the +-- 7 SI base dimensions, along with the dimensions of plane and solid angles. +-- 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 !Int deriving (Show, Eq, Ord) -- | The monoid of dimensions under multiplication. @@ -53,16 +54,18 @@ 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 0 + +dLength, dMass, dTime, dElectricCurrent, dThermodynamicTemperature, dAmountOfSubstance, dLuminousIntensity, dPlaneAngle, dSolidAngle :: Dimension' +dLength = Dim' 1 0 0 0 0 0 0 0 0 +dMass = Dim' 0 1 0 0 0 0 0 0 0 +dTime = Dim' 0 0 1 0 0 0 0 0 0 +dElectricCurrent = Dim' 0 0 0 1 0 0 0 0 0 +dThermodynamicTemperature = Dim' 0 0 0 0 1 0 0 0 0 +dAmountOfSubstance = Dim' 0 0 0 0 0 1 0 0 0 +dLuminousIntensity = Dim' 0 0 0 0 0 0 1 0 0 +dPlaneAngle = Dim' 0 0 0 0 0 0 0 1 0 +dSolidAngle = Dim' 0 0 0 0 0 0 0 0 1 {- We will reuse the operators and function names from the Prelude. @@ -75,21 +78,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 sa) * (Dim' l' m' t' i' th' n' j' pa' sa') = Dim' (l + l') (m + m') (t + t') (i + i') (th + th') (n + n') (j + j') (pa + pa') (sa + sa') -- | 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 sa) / (Dim' l' m' t' i' th' n' j' pa' sa') = Dim' (l - l') (m - m') (t - t') (i - i') (th - th') (n - n') (j - j') (pa - pa') (sa - sa') -- | 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 sa) ^ 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) (x P.* sa) -- | 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 sa) = [l, m, t, i, th, n, j, pa, sa] diff --git a/src/Numeric/Units/Dimensional/DK/Dimensions/TypeLevel.hs b/src/Numeric/Units/Dimensional/DK/Dimensions/TypeLevel.hs index 8f257835..25ab7038 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 and solid 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,7 @@ 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, DSolidAngle, -- * Conversion to Term Level type KnownDimension ) @@ -45,6 +45,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 and solid angles, -- where the respective dimensions are represented by type variables -- using the following convention. -- @@ -55,19 +56,23 @@ import Numeric.Units.Dimensional.DK.Dimensions.TermLevel -- * th: Thermodynamic temperature -- * n: Amount of substance -- * j: Luminous intensity +-- * pa: Plane angle +-- * sa: Solid 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 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 'Zero +type DLength = 'Dim 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero +type DMass = 'Dim 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero +type DTime = 'Dim 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero +type DElectricCurrent = 'Dim 'Zero 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero +type DThermodynamicTemperature = 'Dim 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero +type DAmountOfSubstance = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero +type DLuminousIntensity = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero 'Zero +type DPlaneAngle = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero +type DSolidAngle = 'Dim 'Zero '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 sa) * ('Dim l' m' t' i' th' n' j' pa' sa') + = 'Dim (l + l') (m + m') (t + t') (i + i') (th + th') (n + n') (j + j') (pa + pa') (sa + sa') -- | 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 sa) / ('Dim l' m' t' i' th' n' j' pa' sa') + = 'Dim (l - l') (m - m') (t - t') (i - i') (th - th') (n - n') (j - j') (pa - pa') (sa - sa') -- | 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 sa) ^ 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) (sa N.* x) -- | Roots of dimensions corresponds to division of the base dimensions' -- exponents by the order(?) of the root. @@ -117,8 +122,8 @@ 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 sa) 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) (sa N./ x) -- | 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 +139,9 @@ instance ( KnownTypeInt l , KnownTypeInt th , KnownTypeInt n , KnownTypeInt j - ) => HasDimension (Proxy ('Dim l m t i th n j)) + , KnownTypeInt pa + , KnownTypeInt sa + ) => HasDimension (Proxy ('Dim l m t i th n j pa sa)) where dimension _ = Dim' (toNum (Proxy :: Proxy l)) @@ -144,3 +151,5 @@ instance ( KnownTypeInt l (toNum (Proxy :: Proxy th)) (toNum (Proxy :: Proxy n)) (toNum (Proxy :: Proxy j)) + (toNum (Proxy :: Proxy pa)) + (toNum (Proxy :: Proxy sa)) 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/Quantities.hs b/src/Numeric/Units/Dimensional/DK/Quantities.hs index 164cddbc..95d6dce4 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, @@ -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, @@ -73,8 +73,8 @@ module Numeric.Units.Dimensional.DK.Quantities 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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 'Zero type Inductance = Quantity DInductance -type DLuminousFlux = DLuminousIntensity +type DLuminousFlux = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero 'Pos1 type LuminousFlux = Quantity DLuminousFlux -type DIlluminance = 'Dim 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 +type DIlluminance = 'Dim 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero 'Pos1 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 '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 '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 'Zero 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 'Zero 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 '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 '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 '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 'Zero 'Neg1 type RadiantIntensity = Quantity DRadiantIntensity -type DRadiance = DIrradiance +type DRadiance = 'Dim 'Zero 'Pos1 'Neg3 'Zero 'Zero 'Zero 'Zero 'Zero 'Neg1 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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 'Zero type AbsorbedDoseRate = Quantity DAbsorbedDoseRate {- $not-nist-guide @@ -333,28 +327,28 @@ 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 'Zero type Impulse = Quantity DImpulse -type DMassFlow = 'Dim 'Zero 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero +type DMassFlow = 'Dim 'Zero 'Pos1 'Neg1 'Zero '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 '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 '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 '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 '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 'Zero 'Zero type MomentOfInertia = Quantity DMomentOfInertia -type DAngularMomentum = 'Dim 'Pos2 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero +type DAngularMomentum = 'Dim 'Pos2 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero type AngularMomentum = Quantity DAngularMomentum {- @@ -363,7 +357,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 'Zero type ThermalResistivity = Quantity DThermalResistivity {- @@ -372,35 +366,35 @@ 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 '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 '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 '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 '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 '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 DTorque = 'Dim 'Pos2 'Pos1 'Neg2 'Zero 'Zero 'Zero 'Zero 'Neg1 'Zero type Torque = MomentOfForce -type DTorque = DMomentOfForce -type EnergyPerUnitMass = SpecificEnergy type DEnergyPerUnitMass = DSpecificEnergy +type EnergyPerUnitMass = SpecificEnergy {- $powers-of-length-units It is permissible to express powers of length units by prefixing diff --git a/src/Numeric/Units/Dimensional/DK/SIUnits.hs b/src/Numeric/Units/Dimensional/DK/SIUnits.hs index 02b3bb68..23c70cae 100644 --- a/src/Numeric/Units/Dimensional/DK/SIUnits.hs +++ b/src/Numeric/Units/Dimensional/DK/SIUnits.hs @@ -148,9 +148,9 @@ radian and steradian. -} radian :: Fractional a => Unit DPlaneAngle a -radian = one -- meter * meter ^ neg1 +radian = siUnit steradian :: Fractional a => Unit DSolidAngle a -steradian = one -- meter ^ pos2 * meter ^ neg2 +steradian = siUnit hertz :: Fractional a => Unit DFrequency a hertz = second ^ neg1 newton :: Fractional a => Unit DForce a From c15d0efb65318d928e43525c0db7a5dbaf777cf5 Mon Sep 17 00:00:00 2001 From: Douglas McClean Date: Thu, 16 Jul 2015 15:05:37 -0400 Subject: [PATCH 02/12] Added coerceAngles and removeAngles. --- src/Numeric/Units/Dimensional/DK.hs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Numeric/Units/Dimensional/DK.hs b/src/Numeric/Units/Dimensional/DK.hs index b558c0d5..464d8550 100644 --- a/src/Numeric/Units/Dimensional/DK.hs +++ b/src/Numeric/Units/Dimensional/DK.hs @@ -205,6 +205,8 @@ 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, @@ -232,10 +234,11 @@ import Prelude ) import qualified Prelude import Numeric.NumType.DK.Integers - ( TypeInt (Pos2, Pos3) + ( TypeInt (Zero, Pos2, Pos3) , pos2, pos3 , KnownTypeInt, toNum ) +import Data.Coerce (coerce) import Data.Foldable (Foldable(foldr, foldl')) import Data.Monoid (Monoid(..)) import Data.Ratio ((%)) @@ -591,15 +594,28 @@ asin = (*~ siUnit) . Prelude.asin . (/~ one) acos = (*~ siUnit) . Prelude.acos . (/~ one) atan = (*~ siUnit) . Prelude.atan . (/~ one) +-- | Removes angular dimensions from a dimensional value by equating radians +-- and steradians with the dimensionless quantity one. +removeAngles :: Dimensional v ('Dim l m t i th n j pa sa) a -> Dimensional v ('Dim l m t i th n j 'Zero 'Zero) a +removeAngles = coerceAngles + +-- | Equates values whose dimensions differ in plane or solid angles by equating +-- radians and steradians with the dimensionless quantity one. +-- +-- See `removeAngles`, which offers a more specific result type, if you are only interested +-- in ignoring plane and solid angle dimensions. +coerceAngles :: Dimensional v ('Dim l m t i th n j pa sa) a -> Dimensional v ('Dim l m t i th n j pa' sa') 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 From d1531a3361454905d186b43cb72e456a79e1c284 Mon Sep 17 00:00:00 2001 From: Douglas McClean Date: Thu, 16 Jul 2015 15:16:59 -0400 Subject: [PATCH 03/12] Split baseUnit from siUnit. --- src/Numeric/Units/Dimensional/DK.hs | 34 ++++++++++++++------- src/Numeric/Units/Dimensional/DK/SIUnits.hs | 18 +++++------ 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/Numeric/Units/Dimensional/DK.hs b/src/Numeric/Units/Dimensional/DK.hs index 464d8550..289dee52 100644 --- a/src/Numeric/Units/Dimensional/DK.hs +++ b/src/Numeric/Units/Dimensional/DK.hs @@ -220,7 +220,7 @@ module Numeric.Units.Dimensional.DK -- $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 @@ -585,14 +585,14 @@ acosh = fmap Prelude.acosh atanh = fmap Prelude.atanh sin, cos, tan :: Floating a => PlaneAngle a -> Dimensionless a -sin = (*~ one) . Prelude.sin . (/~ siUnit) -cos = (*~ one) . Prelude.cos . (/~ siUnit) -tan = (*~ one) . Prelude.tan . (/~ siUnit) +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 = (*~ siUnit) . Prelude.asin . (/~ one) -acos = (*~ siUnit) . Prelude.acos . (/~ one) -atan = (*~ siUnit) . Prelude.atan . (/~ one) +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 -- and steradians with the dimensionless quantity one. @@ -618,11 +618,23 @@ of the same type. The result will of course always be a plane angle. 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 or steradians associated +-- with plane or solid 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 and steradians associated +-- with plane or solid angles. +siUnit :: Num a => Unit ('Dim l m t i th n j 'Zero 'Zero) a +siUnit = removeAngles baseUnit {- The only unit we will define in this module is 'one'. @@ -635,7 +647,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 @@ -648,7 +660,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 diff --git a/src/Numeric/Units/Dimensional/DK/SIUnits.hs b/src/Numeric/Units/Dimensional/DK/SIUnits.hs index 23c70cae..71cb38fc 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 :: Fractional a => Unit DPlaneAngle a -radian = siUnit +radian = baseUnit steradian :: Fractional a => Unit DSolidAngle a -steradian = siUnit +steradian = baseUnit hertz :: Fractional a => Unit DFrequency a hertz = second ^ neg1 newton :: Fractional a => Unit DForce a From 24a78392b9355b43d0e86728044b2a1f7e074473 Mon Sep 17 00:00:00 2001 From: Douglas McClean Date: Sat, 18 Jul 2015 14:36:22 -0400 Subject: [PATCH 04/12] Created .SI versions of modules which do not treat angles as dimensions. --- dimensional-dk.cabal | 6 +- src/Numeric/Units/Dimensional/DK/SI.hs | 53 +++++++ .../Units/Dimensional/DK/SI/Prelude.hs | 44 ++++++ .../Units/Dimensional/DK/SI/Quantities.hs | 62 ++++++++ .../Units/Dimensional/DK/SI/SIUnits.hs | 45 ++++++ src/Numeric/Units/Dimensional/DK/SIUnits.hs | 86 ++++++------ .../Units/Dimensional/DK/QuantitiesTest.hs | 132 ++++++++++++------ 7 files changed, 340 insertions(+), 88 deletions(-) create mode 100644 src/Numeric/Units/Dimensional/DK/SI.hs create mode 100644 src/Numeric/Units/Dimensional/DK/SI/Prelude.hs create mode 100644 src/Numeric/Units/Dimensional/DK/SI/Quantities.hs create mode 100644 src/Numeric/Units/Dimensional/DK/SI/SIUnits.hs diff --git a/dimensional-dk.cabal b/dimensional-dk.cabal index 688924b8..1a699a8e 100644 --- a/dimensional-dk.cabal +++ b/dimensional-dk.cabal @@ -51,7 +51,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 diff --git a/src/Numeric/Units/Dimensional/DK/SI.hs b/src/Numeric/Units/Dimensional/DK/SI.hs new file mode 100644 index 00000000..ba62fd52 --- /dev/null +++ b/src/Numeric/Units/Dimensional/DK/SI.hs @@ -0,0 +1,53 @@ +{-# 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 and solid angles are not treated as dimensions. + +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, DSolidAngle, + PlaneAngle, SolidAngle, + baseUnit +) +where + +import qualified Numeric.Units.Dimensional.DK as A +import Numeric.Units.Dimensional.DK hiding (sin, cos, tan, asin, acos, atan, atan2, DPlaneAngle, DSolidAngle, PlaneAngle, SolidAngle, baseUnit) +import Numeric.NumType.DK.Integers + ( TypeInt (Zero) + ) +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 DSolidAngle = DOne + +type PlaneAngle = Quantity DPlaneAngle +type SolidAngle = Quantity DSolidAngle + +baseUnit :: (Num a) => Unit ('Dim l m t i th n j 'Zero 'Zero) 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..849f077c --- /dev/null +++ b/src/Numeric/Units/Dimensional/DK/SI/Prelude.hs @@ -0,0 +1,44 @@ +{- | + 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 and solid angles are not treated as dimensions. + +-} +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..70d884a4 --- /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 and solid angles are not treated as dimensions. + +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, + DLuminousFlux, DIlluminance, DAngularVelocity, DAngularAcceleration, DRadiantIntensity, DRadiance, DAngularMomentum, DTorque +) +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, + DLuminousFlux, DIlluminance, DAngularVelocity, DAngularAcceleration, DRadiantIntensity, DRadiance, DAngularMomentum, DTorque) +import Numeric.NumType.DK.Integers + ( TypeInt (Zero) + ) + +type family RemoveAngles (d :: Dimension) :: Dimension where + RemoveAngles ('Dim l m t i th n j pa sa) = 'Dim l m t i th n j 'Zero 'Zero + +type DLuminousFlux = RemoveAngles A.DLuminousFlux +type LuminousFlux = Quantity DLuminousFlux + +type DIlluminance = RemoveAngles A.DIlluminance +type Illuminance = Quantity DIlluminance + +type DAngularVelocity = RemoveAngles A.DAngularVelocity +type AngularVelocity = Quantity DAngularVelocity + +type DAngularAcceleration = RemoveAngles A.DAngularAcceleration +type AngularAcceleration = Quantity DAngularAcceleration + +type DRadiantIntensity = RemoveAngles A.DRadiantIntensity +type RadiantIntensity = Quantity DRadiantIntensity + +type DRadiance = RemoveAngles A.DRadiance +type Radiance = Quantity DRadiance + +type DAngularMomentum = RemoveAngles A.DAngularMomentum +type AngularMomentum = Quantity DAngularMomentum + +type DTorque = RemoveAngles A.DTorque +type Torque = Quantity DTorque 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..4711a62d --- /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 and solid angles are not treated as dimensions. + +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 DOne a +radian = removeAngles A.radian +steradian = removeAngles A.steradian + +degree, arcminute, arcsecond, degreeOfArc, minuteOfArc, secondOfArc :: (Floating a) => Unit DOne 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 71cb38fc..351a69f8 100644 --- a/src/Numeric/Units/Dimensional/DK/SIUnits.hs +++ b/src/Numeric/Units/Dimensional/DK/SIUnits.hs @@ -60,7 +60,7 @@ where import Numeric.Units.Dimensional.DK import Numeric.Units.Dimensional.DK.Quantities -import Numeric.NumType.DK.Integers ( neg1, neg2, pos2, pos3 ) +import Numeric.NumType.DK.Integers ( pos3 ) import Prelude ( (.), Num, Real, realToFrac, Fractional, Floating, recip ) import qualified Prelude @@ -147,46 +147,46 @@ From Table 3, SI derived units with special names and symbols, including the radian and steradian. -} -radian :: Fractional a => Unit DPlaneAngle a -radian = baseUnit -steradian :: Fractional a => Unit DSolidAngle a -steradian = baseUnit -hertz :: Fractional a => Unit DFrequency a -hertz = second ^ neg1 -newton :: Fractional a => Unit DForce a -newton = kilo gram * meter * second ^ neg2 -pascal :: Fractional a => Unit DPressure a -pascal = newton / meter ^ pos2 -joule :: Fractional a => Unit DEnergy a -joule = newton * meter -watt :: Fractional a => Unit DPower a -watt = joule / second -coulomb :: Fractional a => Unit DElectricCharge a -coulomb = second * ampere -volt :: Fractional a => Unit DElectricPotential a -volt = watt / ampere -farad :: Fractional a => Unit DCapacitance a -farad = coulomb / volt -ohm :: Fractional a => Unit DElectricResistance a -ohm = volt / ampere -siemens :: Fractional a => Unit DElectricConductance a -siemens = ampere / volt -weber :: Fractional a => Unit DMagneticFlux a -weber = volt * second -tesla :: Fractional a => Unit DMagneticFluxDensity a -tesla = weber / meter ^ pos2 -henry :: Fractional a => Unit DInductance a -henry = weber / ampere +radian :: Num a => Unit DPlaneAngle a +radian = baseUnit -- meter * meter ^ neg1 +steradian :: Num a => Unit DSolidAngle a +steradian = baseUnit -- meter ^ pos2 * meter ^ neg2 +hertz :: Num a => Unit DFrequency a +hertz = siUnit -- second ^ neg1 +newton :: Num a => Unit DForce a +newton = siUnit -- kilo gram * meter * second ^ neg2 +pascal :: Num a => Unit DPressure a +pascal = siUnit -- newton / meter ^ pos2 +joule :: Num a => Unit DEnergy a +joule = siUnit -- newton * meter +watt :: Num a => Unit DPower a +watt = siUnit -- joule / second +coulomb :: Num a => Unit DElectricCharge a +coulomb = siUnit -- second * ampere +volt :: Num a => Unit DElectricPotential a +volt = siUnit -- watt / ampere +farad :: Num a => Unit DCapacitance a +farad = siUnit -- coulomb / volt +ohm :: Num a => Unit DElectricResistance a +ohm = siUnit -- volt / ampere +siemens :: Num a => Unit DElectricConductance a +siemens = siUnit -- ampere / volt +weber :: Num a => Unit DMagneticFlux a +weber = siUnit -- volt * second +tesla :: Num a => Unit DMagneticFluxDensity a +tesla = siUnit -- weber / meter ^ pos2 +henry :: Num a => Unit DInductance a +henry = siUnit -- weber / ampere {- We defer the definition of Celcius temperature to another section (would appear here if we stricly followed table 3). -} -lumen :: Fractional a => Unit DLuminousFlux a -lumen = candela * steradian -lux :: Fractional a => Unit DIlluminance a -lux = lumen / meter ^ pos2 +lumen :: Num a => Unit DLuminousFlux a +lumen = baseUnit -- candela * steradian +lux :: Num a => Unit DIlluminance a +lux = baseUnit -- lumen / meter ^ pos2 {- $celsius A problematic area is units which increase proportionally to the @@ -216,14 +216,14 @@ The last units from Table 3 are SI derived units with special names and symbols of safeguarding human health. -} -becquerel :: Fractional a => Unit DActivity a -becquerel = second ^ neg1 -gray :: Fractional a => Unit DAbsorbedDose a -gray = joule / kilo gram -sievert :: Fractional a => Unit DDoseEquivalent a -sievert = joule / kilo gram -katal :: Fractional a => Unit DCatalyticActivity a -katal = mole / second +becquerel :: Num a => Unit DActivity a +becquerel = siUnit -- second ^ neg1 +gray :: Num a => Unit DAbsorbedDose a +gray = siUnit -- joule / kilo gram +sievert :: Num a => Unit DDoseEquivalent a +sievert = siUnit -- joule / kilo gram +katal :: Num a => Unit DCatalyticActivity a +katal = siUnit -- mole / second {- $accepted-units There are several units that are not strictly part of the SI but diff --git a/tests/Numeric/Units/Dimensional/DK/QuantitiesTest.hs b/tests/Numeric/Units/Dimensional/DK/QuantitiesTest.hs index 7217da19..52095160 100644 --- a/tests/Numeric/Units/Dimensional/DK/QuantitiesTest.hs +++ b/tests/Numeric/Units/Dimensional/DK/QuantitiesTest.hs @@ -30,54 +30,98 @@ x10 = 1 *~ (mole / meter ^ pos3) x11 :: Luminance Double x11 = 1 *~ (candela / meter ^ pos2) --- Tables 3a and 3b are implicitely tested by the corresponding --- unit definitions. +-- These definitions simply verify that the type synonyms are +-- consistent with the appropriate units from table 3. If the +-- definitions compile the type synonyms are good. + +y1 :: PlaneAngle Double +y1 = coerceAngles $ 1 *~ (meter / meter) +y2 :: SolidAngle Double +y2 = coerceAngles $ 1 *~ (meter ^ pos2 / meter ^ pos2) +y3 :: Frequency Double +y3 = 1 *~ (one / second) +y4 :: Force Double +y4 = 1 *~ (meter * kilo gram / second ^ pos2) +y5 :: Pressure Double +y5 = 1 *~ (newton / meter ^ pos2) +y6 :: Energy Double +y6 = 1 *~ (newton * meter) +y7 :: Power Double +y7 = 1 *~ (joule / second) +y8 :: ElectricCharge Double +y8 = 1 *~ (second * ampere) +y9 :: ElectricPotential Double +y9 = 1 *~ (watt / ampere) +y10 :: Capacitance Double +y10 = 1 *~ (coulomb / volt) +y11 :: ElectricResistance Double +y11 = 1 *~ (volt / ampere) +y12 :: ElectricConductance Double +y12 = 1 *~ (ampere / volt) +y13 :: MagneticFlux Double +y13 = 1 *~ (volt * second) +y14 :: MagneticFluxDensity Double +y14 = 1 *~ (weber / meter ^ pos2) +y15 :: Inductance Double +y15 = 1 *~ (weber / ampere) +y16 :: LuminousFlux Double +y16 = 1 *~ (candela * steradian) +y17 :: Illuminance Double +y17 = 1 *~ (lumen / meter ^ pos2) +y18 :: Activity Double +y18 = 1 *~ (one / second) +y19 :: AbsorbedDose Double +y19 = 1 *~ (joule / kilo gram) +y20 :: DoseEquivalent Double +y20 = 1 *~ (joule / kilo gram) +y21 :: CatalyticActivity Double +y21 = 1 *~ (mole / second) -- Verification of table 4. If the definitions compile the type -- synonyms are good. -y1 :: AngularVelocity Double -y1 = 1 *~ (radian / second) -y2 :: AngularAcceleration Double -y2 = 1 *~ (radian / second ^ pos2) -y3 :: DynamicViscosity Double -y3 = 1 *~ (pascal * second) -y4 :: MomentOfForce Double -y4 = 1 *~ (newton * meter) -y5 :: SurfaceTension Double -y5 = 1 *~ (newton / meter) -y6 :: HeatFluxDensity Double -y6 = 1 *~ (watt / meter ^ pos2) -y7 :: RadiantIntensity Double -y7 = 1 *~ (watt / steradian) -y8 :: Radiance Double -y8 = 1 *~ (watt / (meter ^ pos2 * steradian)) -y9 :: HeatCapacity Double -y9 = 1 *~ (joule / kelvin) -y10 :: SpecificHeatCapacity Double -y10 = 1 *~ (joule / (kilo gram * kelvin)) -y11 :: ThermalConductivity Double -y11 = 1 *~ (watt / (meter * kelvin)) -y12 :: EnergyDensity Double -y12 = 1 *~ (joule / meter ^ pos3) -y13 :: ElectricFieldStrength Double -y13 = 1 *~ (volt / meter) -y14 :: ElectricChargeDensity Double -y14 = 1 *~ (coulomb / meter ^ pos3) -y15 :: ElectricFluxDensity Double -y15 = 1 *~ (coulomb / meter ^ pos2) -y16 :: Permittivity Double -y16 = 1 *~ (farad / meter) -y17 :: Permeability Double -y17 = 1 *~ (henry / meter) -y18 :: MolarEnergy Double -y18 = 1 *~ (joule / mole) -y19 :: MolarEntropy Double -y19 = 1 *~ (joule / (mole * kelvin)) -y20 :: Exposure Double -y20 = 1 *~ (coulomb / kilo gram) -y21 :: AbsorbedDoseRate Double -y21 = 1 *~ (gray / second) +z1 :: AngularVelocity Double +z1 = 1 *~ (radian / second) +z2 :: AngularAcceleration Double +z2 = 1 *~ (radian / second ^ pos2) +z3 :: DynamicViscosity Double +z3 = 1 *~ (pascal * second) +z4 :: MomentOfForce Double +z4 = 1 *~ (newton * meter) +z5 :: SurfaceTension Double +z5 = 1 *~ (newton / meter) +z6 :: HeatFluxDensity Double +z6 = 1 *~ (watt / meter ^ pos2) +z7 :: RadiantIntensity Double +z7 = 1 *~ (watt / steradian) +z8 :: Radiance Double +z8 = 1 *~ (watt / (meter ^ pos2 * steradian)) +z9 :: HeatCapacity Double +z9 = 1 *~ (joule / kelvin) +z10 :: SpecificHeatCapacity Double +z10 = 1 *~ (joule / (kilo gram * kelvin)) +z11 :: ThermalConductivity Double +z11 = 1 *~ (watt / (meter * kelvin)) +z12 :: EnergyDensity Double +z12 = 1 *~ (joule / meter ^ pos3) +z13 :: ElectricFieldStrength Double +z13 = 1 *~ (volt / meter) +z14 :: ElectricChargeDensity Double +z14 = 1 *~ (coulomb / meter ^ pos3) +z15 :: ElectricFluxDensity Double +z15 = 1 *~ (coulomb / meter ^ pos2) +z16 :: Permittivity Double +z16 = 1 *~ (farad / meter) +z17 :: Permeability Double +z17 = 1 *~ (henry / meter) +z18 :: MolarEnergy Double +z18 = 1 *~ (joule / mole) +z19 :: MolarEntropy Double +z19 = 1 *~ (joule / (mole * kelvin)) +z20 :: Exposure Double +z20 = 1 *~ (coulomb / kilo gram) +z21 :: AbsorbedDoseRate Double +z21 = 1 *~ (gray / second) -- Other quantitites. mu :: GravitationalParameter Double From 475a932aeed6d5842b6f376f8b40fec14edc506e Mon Sep 17 00:00:00 2001 From: Douglas McClean Date: Sat, 18 Jul 2015 17:24:45 -0400 Subject: [PATCH 05/12] Hid coerceAngles and removeAngles from the Prelude. --- src/Numeric/Units/Dimensional/DK/Prelude.hs | 1 + tests/Numeric/Units/Dimensional/DK/QuantitiesTest.hs | 1 + 2 files changed, 2 insertions(+) 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/tests/Numeric/Units/Dimensional/DK/QuantitiesTest.hs b/tests/Numeric/Units/Dimensional/DK/QuantitiesTest.hs index 52095160..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 From 4510cd6f8937b7164e72a33b58742f1394d78da1 Mon Sep 17 00:00:00 2001 From: Douglas McClean Date: Sat, 18 Jul 2015 17:30:11 -0400 Subject: [PATCH 06/12] Added angular units to displayed form of quantities. --- src/Numeric/Units/Dimensional/DK.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Numeric/Units/Dimensional/DK.hs b/src/Numeric/Units/Dimensional/DK.hs index 289dee52..6856859f 100644 --- a/src/Numeric/Units/Dimensional/DK.hs +++ b/src/Numeric/Units/Dimensional/DK.hs @@ -725,7 +725,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 From 4db8b5a1c1b272e383c3c8eda2d3e8bbafa878f0 Mon Sep 17 00:00:00 2001 From: Douglas McClean Date: Sat, 18 Jul 2015 17:30:27 -0400 Subject: [PATCH 07/12] Corrected definition of Torque to use angular basis. --- src/Numeric/Units/Dimensional/DK/Quantities.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Numeric/Units/Dimensional/DK/Quantities.hs b/src/Numeric/Units/Dimensional/DK/Quantities.hs index 95d6dce4..eab92406 100644 --- a/src/Numeric/Units/Dimensional/DK/Quantities.hs +++ b/src/Numeric/Units/Dimensional/DK/Quantities.hs @@ -391,7 +391,7 @@ type DThrust = DForce type Thrust = Force type DTorque = 'Dim 'Pos2 'Pos1 'Neg2 'Zero 'Zero 'Zero 'Zero 'Neg1 'Zero -type Torque = MomentOfForce +type Torque = Quantity DTorque type DEnergyPerUnitMass = DSpecificEnergy type EnergyPerUnitMass = SpecificEnergy From 0f79c8569e1ba90be0d68f0c385bb33003301acc Mon Sep 17 00:00:00 2001 From: Douglas McClean Date: Sun, 19 Jul 2015 09:42:57 -0400 Subject: [PATCH 08/12] Refactoring and documentation of ToSIDim type family. --- src/Numeric/Units/Dimensional/DK.hs | 8 +++---- .../Dimensional/DK/Dimensions/TypeLevel.hs | 20 +++++++++++++++++ src/Numeric/Units/Dimensional/DK/SI.hs | 5 +---- .../Units/Dimensional/DK/SI/Quantities.hs | 22 +++++++------------ .../Units/Dimensional/DK/SI/SIUnits.hs | 4 ++-- 5 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/Numeric/Units/Dimensional/DK.hs b/src/Numeric/Units/Dimensional/DK.hs index 6856859f..7009a10f 100644 --- a/src/Numeric/Units/Dimensional/DK.hs +++ b/src/Numeric/Units/Dimensional/DK.hs @@ -195,7 +195,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, @@ -234,7 +234,7 @@ import Prelude ) import qualified Prelude import Numeric.NumType.DK.Integers - ( TypeInt (Zero, Pos2, Pos3) + ( TypeInt (Pos2, Pos3) , pos2, pos3 , KnownTypeInt, toNum ) @@ -596,7 +596,7 @@ atan = (*~ baseUnit) . Prelude.atan . (/~ one) -- | Removes angular dimensions from a dimensional value by equating radians -- and steradians with the dimensionless quantity one. -removeAngles :: Dimensional v ('Dim l m t i th n j pa sa) a -> Dimensional v ('Dim l m t i th n j 'Zero 'Zero) a +removeAngles :: Dimensional v ('Dim l m t i th n j pa sa) a -> Dimensional v (SIDim l m t i th n j) a removeAngles = coerceAngles -- | Equates values whose dimensions differ in plane or solid angles by equating @@ -633,7 +633,7 @@ baseUnit = Dimensional 1 -- -- `baseUnit` is similar but includes the radians and steradians associated -- with plane or solid angles. -siUnit :: Num a => Unit ('Dim l m t i th n j 'Zero 'Zero) a +siUnit :: Num a => Unit (SIDim l m t i th n j) a siUnit = removeAngles baseUnit {- diff --git a/src/Numeric/Units/Dimensional/DK/Dimensions/TypeLevel.hs b/src/Numeric/Units/Dimensional/DK/Dimensions/TypeLevel.hs index 25ab7038..e7441e98 100644 --- a/src/Numeric/Units/Dimensional/DK/Dimensions/TypeLevel.hs +++ b/src/Numeric/Units/Dimensional/DK/Dimensions/TypeLevel.hs @@ -31,6 +31,8 @@ module Numeric.Units.Dimensional.DK.Dimensions.TypeLevel -- * Synonyms for Base Dimensions DOne, DLength, DMass, DTime, DElectricCurrent, DThermodynamicTemperature, DAmountOfSubstance, DLuminousIntensity, DPlaneAngle, DSolidAngle, + -- * Conversion to SI Basis + type SIDim, type ToSIDim, -- * Conversion to Term Level type KnownDimension ) @@ -125,6 +127,24 @@ type family Root (d::Dimension) (x::TypeInt) where Root ('Dim l m t i th n j pa sa) 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) (sa 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 'Zero + +-- | Projects a 'Dimension' in the extended basis including plane and solid angles to +-- the SI basis. +type family ToSIDim (d :: Dimension) :: Dimension where + ToSIDim ('Dim l m t i th n j pa sa) = 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. -- diff --git a/src/Numeric/Units/Dimensional/DK/SI.hs b/src/Numeric/Units/Dimensional/DK/SI.hs index ba62fd52..5de24901 100644 --- a/src/Numeric/Units/Dimensional/DK/SI.hs +++ b/src/Numeric/Units/Dimensional/DK/SI.hs @@ -27,9 +27,6 @@ where import qualified Numeric.Units.Dimensional.DK as A import Numeric.Units.Dimensional.DK hiding (sin, cos, tan, asin, acos, atan, atan2, DPlaneAngle, DSolidAngle, PlaneAngle, SolidAngle, baseUnit) -import Numeric.NumType.DK.Integers - ( TypeInt (Zero) - ) import Prelude hiding (sin, cos, tan, asin, acos, atan, atan2) sin, cos, tan, asin, acos, atan :: (Floating a) => Dimensionless a -> Dimensionless a @@ -49,5 +46,5 @@ type DSolidAngle = DOne type PlaneAngle = Quantity DPlaneAngle type SolidAngle = Quantity DSolidAngle -baseUnit :: (Num a) => Unit ('Dim l m t i th n j 'Zero 'Zero) a +baseUnit :: (Num a) => Unit (SIDim l m t i th n j) a baseUnit = siUnit diff --git a/src/Numeric/Units/Dimensional/DK/SI/Quantities.hs b/src/Numeric/Units/Dimensional/DK/SI/Quantities.hs index 70d884a4..68aebe30 100644 --- a/src/Numeric/Units/Dimensional/DK/SI/Quantities.hs +++ b/src/Numeric/Units/Dimensional/DK/SI/Quantities.hs @@ -30,33 +30,27 @@ 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, DLuminousFlux, DIlluminance, DAngularVelocity, DAngularAcceleration, DRadiantIntensity, DRadiance, DAngularMomentum, DTorque) -import Numeric.NumType.DK.Integers - ( TypeInt (Zero) - ) -type family RemoveAngles (d :: Dimension) :: Dimension where - RemoveAngles ('Dim l m t i th n j pa sa) = 'Dim l m t i th n j 'Zero 'Zero - -type DLuminousFlux = RemoveAngles A.DLuminousFlux +type DLuminousFlux = ToSIDim A.DLuminousFlux type LuminousFlux = Quantity DLuminousFlux -type DIlluminance = RemoveAngles A.DIlluminance +type DIlluminance = ToSIDim A.DIlluminance type Illuminance = Quantity DIlluminance -type DAngularVelocity = RemoveAngles A.DAngularVelocity +type DAngularVelocity = ToSIDim A.DAngularVelocity type AngularVelocity = Quantity DAngularVelocity -type DAngularAcceleration = RemoveAngles A.DAngularAcceleration +type DAngularAcceleration = ToSIDim A.DAngularAcceleration type AngularAcceleration = Quantity DAngularAcceleration -type DRadiantIntensity = RemoveAngles A.DRadiantIntensity +type DRadiantIntensity = ToSIDim A.DRadiantIntensity type RadiantIntensity = Quantity DRadiantIntensity -type DRadiance = RemoveAngles A.DRadiance +type DRadiance = ToSIDim A.DRadiance type Radiance = Quantity DRadiance -type DAngularMomentum = RemoveAngles A.DAngularMomentum +type DAngularMomentum = ToSIDim A.DAngularMomentum type AngularMomentum = Quantity DAngularMomentum -type DTorque = RemoveAngles A.DTorque +type DTorque = ToSIDim A.DTorque type Torque = Quantity DTorque diff --git a/src/Numeric/Units/Dimensional/DK/SI/SIUnits.hs b/src/Numeric/Units/Dimensional/DK/SI/SIUnits.hs index 4711a62d..3bab7ba6 100644 --- a/src/Numeric/Units/Dimensional/DK/SI/SIUnits.hs +++ b/src/Numeric/Units/Dimensional/DK/SI/SIUnits.hs @@ -27,11 +27,11 @@ 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 DOne a +radian, steradian :: (Num a) => Unit DPlaneAngle a radian = removeAngles A.radian steradian = removeAngles A.steradian -degree, arcminute, arcsecond, degreeOfArc, minuteOfArc, secondOfArc :: (Floating a) => Unit DOne a +degree, arcminute, arcsecond, degreeOfArc, minuteOfArc, secondOfArc :: (Floating a) => Unit DPlaneAngle a degree = removeAngles A.degree arcminute = removeAngles A.arcminute arcsecond = removeAngles A.arcsecond From 42b5259fa60df037c7e2c02b451263f29c195cec Mon Sep 17 00:00:00 2001 From: Douglas McClean Date: Fri, 18 Sep 2015 22:29:50 -0400 Subject: [PATCH 09/12] Corrected dimensions of angular momentum and moment of inertia. --- src/Numeric/Units/Dimensional/DK/Quantities.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Numeric/Units/Dimensional/DK/Quantities.hs b/src/Numeric/Units/Dimensional/DK/Quantities.hs index eab92406..b2e0ca49 100644 --- a/src/Numeric/Units/Dimensional/DK/Quantities.hs +++ b/src/Numeric/Units/Dimensional/DK/Quantities.hs @@ -345,10 +345,10 @@ type KinematicViscosity = Quantity DKinematicViscosity type DFirstMassMoment = 'Dim 'Pos1 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero type FirstMassMoment = Quantity DFirstMassMoment -type DMomentOfInertia = 'Dim 'Pos2 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero +type DMomentOfInertia = 'Dim 'Pos2 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Neg2 'Zero type MomentOfInertia = Quantity DMomentOfInertia -type DAngularMomentum = 'Dim 'Pos2 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero +type DAngularMomentum = 'Dim 'Pos2 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero 'Neg1 'Zero type AngularMomentum = Quantity DAngularMomentum {- From 650d8b5f15a5b40d798847e7f4cdff6b6f6e9d7e Mon Sep 17 00:00:00 2001 From: Douglas McClean Date: Sat, 19 Sep 2015 12:10:20 -0400 Subject: [PATCH 10/12] Added SI definition of DMomentOfInertia, mistakenly omitted from the previous commit. --- src/Numeric/Units/Dimensional/DK/SI/Quantities.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Numeric/Units/Dimensional/DK/SI/Quantities.hs b/src/Numeric/Units/Dimensional/DK/SI/Quantities.hs index 68aebe30..f61f6e3e 100644 --- a/src/Numeric/Units/Dimensional/DK/SI/Quantities.hs +++ b/src/Numeric/Units/Dimensional/DK/SI/Quantities.hs @@ -21,15 +21,15 @@ module Numeric.Units.Dimensional.DK.SI.Quantities ( module Numeric.Units.Dimensional.DK.Quantities, - LuminousFlux, Illuminance, AngularVelocity, AngularAcceleration, RadiantIntensity, Radiance, AngularMomentum, Torque, - DLuminousFlux, DIlluminance, DAngularVelocity, DAngularAcceleration, DRadiantIntensity, DRadiance, DAngularMomentum, DTorque + LuminousFlux, Illuminance, AngularVelocity, AngularAcceleration, RadiantIntensity, Radiance, AngularMomentum, Torque, MomentOfInertia, + DLuminousFlux, DIlluminance, DAngularVelocity, DAngularAcceleration, DRadiantIntensity, DRadiance, DAngularMomentum, DTorque, DMomentOfInertia ) 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, - DLuminousFlux, DIlluminance, DAngularVelocity, DAngularAcceleration, DRadiantIntensity, DRadiance, DAngularMomentum, DTorque) +import Numeric.Units.Dimensional.DK.Quantities hiding (LuminousFlux, Illuminance, AngularVelocity, AngularAcceleration, RadiantIntensity, Radiance, AngularMomentum, Torque, MomentOfInertia, + DLuminousFlux, DIlluminance, DAngularVelocity, DAngularAcceleration, DRadiantIntensity, DRadiance, DAngularMomentum, DTorque, DMomentOfInertia) type DLuminousFlux = ToSIDim A.DLuminousFlux type LuminousFlux = Quantity DLuminousFlux @@ -54,3 +54,6 @@ type AngularMomentum = Quantity DAngularMomentum type DTorque = ToSIDim A.DTorque type Torque = Quantity DTorque + +type DMomentOfInertia = ToSIDim A.DMomentOfInertia +type MomentOfInertia = Quantity DMomentOfInertia From 48fd3746e752f7e94d3f670f320ee8cf7763c78d Mon Sep 17 00:00:00 2001 From: Douglas McClean Date: Wed, 21 Oct 2015 10:39:25 -0400 Subject: [PATCH 11/12] Treat solid angle as the square of plane angle. --- src/Numeric/Units/Dimensional/DK.hs | 25 ++-- .../Dimensional/DK/Dimensions/TermLevel.hs | 41 +++--- .../Dimensional/DK/Dimensions/TypeLevel.hs | 55 ++++---- .../Units/Dimensional/DK/Quantities.hs | 131 +++++++++--------- src/Numeric/Units/Dimensional/DK/SI.hs | 10 +- .../Units/Dimensional/DK/SI/Prelude.hs | 5 +- .../Units/Dimensional/DK/SI/Quantities.hs | 13 +- .../Units/Dimensional/DK/SI/SIUnits.hs | 2 +- 8 files changed, 140 insertions(+), 142 deletions(-) diff --git a/src/Numeric/Units/Dimensional/DK.hs b/src/Numeric/Units/Dimensional/DK.hs index 7ceff6de..108fa88c 100644 --- a/src/Numeric/Units/Dimensional/DK.hs +++ b/src/Numeric/Units/Dimensional/DK.hs @@ -216,10 +216,10 @@ module Numeric.Units.Dimensional.DK (*~~), (/~~), sum, mean, dimensionlessLength, nFromTo, -- * Dimension Synonyms -- $dimension-synonyms - DOne, DLength, DMass, DTime, DElectricCurrent, DThermodynamicTemperature, DAmountOfSubstance, DLuminousIntensity, DPlaneAngle, DSolidAngle, + DOne, DLength, DMass, DTime, DElectricCurrent, DThermodynamicTemperature, DAmountOfSubstance, DLuminousIntensity, DPlaneAngle, -- * Quantity Synonyms -- $quantity-synonyms - Dimensionless, Length, Mass, Time, ElectricCurrent, ThermodynamicTemperature, AmountOfSubstance, LuminousIntensity, PlaneAngle, SolidAngle, + Dimensionless, Length, Mass, Time, ElectricCurrent, ThermodynamicTemperature, AmountOfSubstance, LuminousIntensity, PlaneAngle, -- * Constants -- $constants _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, pi, tau, @@ -388,7 +388,6 @@ type ThermodynamicTemperature = Quantity DThermodynamicTemperature type AmountOfSubstance = Quantity DAmountOfSubstance type LuminousIntensity = Quantity DLuminousIntensity type PlaneAngle = Quantity DPlaneAngle -type SolidAngle = Quantity DSolidAngle {- $dimension-arithmetic When performing arithmetic on units and quantities the arithmetics @@ -607,16 +606,16 @@ acos = (*~ baseUnit) . Prelude.acos . (/~ one) atan = (*~ baseUnit) . Prelude.atan . (/~ one) -- | Removes angular dimensions from a dimensional value by equating radians --- and steradians with the dimensionless quantity one. -removeAngles :: Dimensional v ('Dim l m t i th n j pa sa) a -> Dimensional v (SIDim l m t i th n j) a +-- 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 or solid angles by equating --- radians and steradians with the dimensionless quantity one. +-- | 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 plane and solid angle dimensions. -coerceAngles :: Dimensional v ('Dim l m t i th n j pa sa) a -> Dimensional v ('Dim l m t i th n j pa' sa') a +-- 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 @@ -634,8 +633,8 @@ atan2 (Dimensional y) (Dimensional x) = Dimensional (Prelude.atan2 y x) -- 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 or steradians associated --- with plane or solid angles. +-- `siUnit` is similar but does not include the radians associated +-- with plane angles. baseUnit :: Num a => Unit d a baseUnit = Dimensional 1 @@ -643,8 +642,8 @@ baseUnit = Dimensional 1 -- SI base unit of any dimension. This allows polymorphic quantity -- creation and destruction without exposing the 'Dimensional' constructor. -- --- `baseUnit` is similar but includes the radians and steradians associated --- with plane or solid angles. +-- `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 diff --git a/src/Numeric/Units/Dimensional/DK/Dimensions/TermLevel.hs b/src/Numeric/Units/Dimensional/DK/Dimensions/TermLevel.hs index 9608ebea..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 along with plane and solid angles, 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, dPlaneAngle, dSolidAngle, + dLength, dMass, dTime, dElectricCurrent, dThermodynamicTemperature, dAmountOfSubstance, dLuminousIntensity, dPlaneAngle, -- * Deconstruction asList ) @@ -32,11 +32,11 @@ import Data.Monoid (Monoid(..)) import Prelude (id, (+), (-), Int, Show, Eq, Ord) import qualified Prelude as P --- | A physical dimension, encoded as 9 integers, representing a factorization of the dimension into the --- 7 SI base dimensions, along with the dimensions of plane and solid angles. +-- | 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 !Int !Int +data Dimension' = Dim' !Int !Int !Int !Int !Int !Int !Int !Int deriving (Show, Eq, Ord) -- | The monoid of dimensions under multiplication. @@ -54,18 +54,17 @@ instance HasDimension Dimension' where -- | The dimension of dimensionless values. dOne :: Dimension' -dOne = Dim' 0 0 0 0 0 0 0 0 0 - -dLength, dMass, dTime, dElectricCurrent, dThermodynamicTemperature, dAmountOfSubstance, dLuminousIntensity, dPlaneAngle, dSolidAngle :: Dimension' -dLength = Dim' 1 0 0 0 0 0 0 0 0 -dMass = Dim' 0 1 0 0 0 0 0 0 0 -dTime = Dim' 0 0 1 0 0 0 0 0 0 -dElectricCurrent = Dim' 0 0 0 1 0 0 0 0 0 -dThermodynamicTemperature = Dim' 0 0 0 0 1 0 0 0 0 -dAmountOfSubstance = Dim' 0 0 0 0 0 1 0 0 0 -dLuminousIntensity = Dim' 0 0 0 0 0 0 1 0 0 -dPlaneAngle = Dim' 0 0 0 0 0 0 0 1 0 -dSolidAngle = Dim' 0 0 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. @@ -78,15 +77,15 @@ infixl 7 *, / -- | Forms the product of two dimensions. (*) :: Dimension' -> Dimension' -> Dimension' -(Dim' l m t i th n j pa sa) * (Dim' l' m' t' i' th' n' j' pa' sa') = Dim' (l + l') (m + m') (t + t') (i + i') (th + th') (n + n') (j + j') (pa + pa') (sa + sa') +(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 pa sa) / (Dim' l' m' t' i' th' n' j' pa' sa') = Dim' (l - l') (m - m') (t - t') (i - i') (th - th') (n - n') (j - j') (pa - pa') (sa - sa') +(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 pa sa) ^ 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) (x P.* sa) +(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' @@ -95,4 +94,4 @@ recip = (dOne /) -- | 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 pa sa) = [l, m, t, i, th, n, j, pa, sa] +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 e7441e98..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 along with plane and solid angles 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,7 @@ 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, DPlaneAngle, DSolidAngle, + DLength, DMass, DTime, DElectricCurrent, DThermodynamicTemperature, DAmountOfSubstance, DLuminousIntensity, DPlaneAngle, -- * Conversion to SI Basis type SIDim, type ToSIDim, -- * Conversion to Term Level @@ -47,7 +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 and solid angles, +-- along with the dimensions of plane angle, -- where the respective dimensions are represented by type variables -- using the following convention. -- @@ -59,22 +59,20 @@ import Numeric.Units.Dimensional.DK.Dimensions.TermLevel -- * n: Amount of substance -- * j: Luminous intensity -- * pa: Plane angle --- * sa: Solid angle -- -- For the equivalent term-level representation, see 'Dimension'' -data Dimension = Dim TypeInt TypeInt 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 'Zero 'Zero -type DLength = 'Dim 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero -type DMass = 'Dim 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero -type DTime = 'Dim 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero -type DElectricCurrent = 'Dim 'Zero 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero 'Zero -type DThermodynamicTemperature = 'Dim 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero -type DAmountOfSubstance = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero -type DLuminousIntensity = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero 'Zero -type DPlaneAngle = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero -type DSolidAngle = 'Dim 'Zero 'Zero '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. @@ -90,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 pa sa) * ('Dim l' m' t' i' th' n' j' pa' sa') - = 'Dim (l + l') (m + m') (t + t') (i + i') (th + th') (n + n') (j + j') (pa + pa') (sa + sa') + ('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 pa sa) / ('Dim l' m' t' i' th' n' j' pa' sa') - = 'Dim (l - l') (m - m') (t - t') (i - i') (th - th') (n - n') (j - j') (pa - pa') (sa - sa') + ('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. @@ -114,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 pa sa) ^ 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) (sa 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. @@ -124,8 +122,8 @@ 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 pa sa) 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) (sa 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 @@ -138,12 +136,11 @@ type family Root (d::Dimension) (x::TypeInt) where -- * 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 'Zero +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 and solid angles to --- the SI basis. +-- | 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 sa) = SIDim l m t i th n j + 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. @@ -160,8 +157,7 @@ instance ( KnownTypeInt l , KnownTypeInt n , KnownTypeInt j , KnownTypeInt pa - , KnownTypeInt sa - ) => HasDimension (Proxy ('Dim l m t i th n j pa sa)) + ) => HasDimension (Proxy ('Dim l m t i th n j pa)) where dimension _ = Dim' (toNum (Proxy :: Proxy l)) @@ -172,4 +168,3 @@ instance ( KnownTypeInt l (toNum (Proxy :: Proxy n)) (toNum (Proxy :: Proxy j)) (toNum (Proxy :: Proxy pa)) - (toNum (Proxy :: Proxy sa)) diff --git a/src/Numeric/Units/Dimensional/DK/Quantities.hs b/src/Numeric/Units/Dimensional/DK/Quantities.hs index b2e0ca49..37751cbe 100644 --- a/src/Numeric/Units/Dimensional/DK/Quantities.hs +++ b/src/Numeric/Units/Dimensional/DK/Quantities.hs @@ -49,7 +49,7 @@ module Numeric.Units.Dimensional.DK.Quantities -- $not-nist-guide Impulse, 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, @@ -68,7 +68,7 @@ module Numeric.Units.Dimensional.DK.Quantities DMolarEnergy, DMolarEntropy, DMolarHeatCapacity, DExposure, DAbsorbedDoseRate, DImpulse, 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 @@ -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 '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 '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 '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 '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 '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 '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 '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 '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 '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 'Zero '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 'Zero 'Zero +type DLuminance = 'Dim 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero type Luminance = Quantity DLuminance @@ -149,63 +149,63 @@ SI coherent derived units with special names and symbols. -} -type DFrequency = 'Dim 'Zero 'Zero 'Neg1 'Zero 'Zero '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 '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 'Zero 'Zero +type DInductance = 'Dim 'Pos2 'Pos1 'Neg2 'Neg2 'Zero 'Zero 'Zero 'Zero type Inductance = Quantity DInductance -type DLuminousFlux = 'Dim 'Zero 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero 'Pos1 +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 'Zero 'Pos1 +type DIlluminance = 'Dim 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero 'Pos1 'Pos2 type Illuminance = Quantity DIlluminance type DCelsiusTemperature = DThermodynamicTemperature @@ -214,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 'Zero 'Zero +type DAbsorbedDose = 'Dim 'Pos2 'Zero 'Neg2 'Zero 'Zero 'Zero 'Zero 'Zero type DSpecificEnergy = DAbsorbedDose type DKerma = DAbsorbedDose type AbsorbedDose = Quantity DAbsorbedDose @@ -232,7 +232,7 @@ type DirectionalDoseEquivalent = DoseEquivalent type PersonalDoseEquivalent = DoseEquivalent type EquivalentDose = DoseEquivalent -type DCatalyticActivity = 'Dim 'Zero 'Zero 'Neg1 'Zero 'Zero 'Pos1 'Zero 'Zero 'Zero +type DCatalyticActivity = 'Dim 'Zero 'Zero 'Neg1 'Zero 'Zero 'Pos1 'Zero 'Zero type CatalyticActivity = Quantity DCatalyticActivity {- $table4 @@ -245,38 +245,38 @@ We use the same grouping as for table 2. -} -type DAngularVelocity = 'Dim 'Zero 'Zero 'Neg1 'Zero 'Zero 'Zero 'Zero 'Pos1 'Zero +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 'Pos1 '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 '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 '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 '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 = 'Dim 'Pos2 'Pos1 'Neg3 'Zero 'Zero 'Zero 'Zero 'Zero 'Neg1 +type DRadiantIntensity = 'Dim 'Pos2 'Pos1 'Neg3 'Zero 'Zero 'Zero 'Zero 'Neg2 type RadiantIntensity = Quantity DRadiantIntensity -type DRadiance = 'Dim 'Zero 'Pos1 'Neg3 'Zero 'Zero 'Zero 'Zero 'Zero 'Neg1 +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 '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 'Zero 'Zero +type DSpecificHeatCapacity = 'Dim 'Pos2 'Zero 'Neg2 'Zero 'Neg1 'Zero 'Zero 'Zero type DSpecificEntropy = DSpecificHeatCapacity type SpecificHeatCapacity = Quantity DSpecificHeatCapacity type SpecificEntropy = Quantity DSpecificEntropy @@ -287,39 +287,39 @@ Specific energy was already defined in table 3. -} -type DThermalConductivity = 'Dim 'Pos1 'Pos1 'Neg3 'Zero 'Neg1 'Zero 'Zero '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 '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 '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 '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 '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 '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 'Zero '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 'Zero '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 '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 'Zero 'Zero +type DAbsorbedDoseRate = 'Dim 'Pos2 'Zero 'Neg3 'Zero 'Zero 'Zero 'Zero 'Zero type AbsorbedDoseRate = Quantity DAbsorbedDoseRate {- $not-nist-guide @@ -327,28 +327,28 @@ 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 'Zero 'Zero +type DImpulse = 'Dim 'Pos1 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero 'Zero type Impulse = Quantity DImpulse -type DMassFlow = 'Dim 'Zero 'Pos1 'Neg1 'Zero 'Zero '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 '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 '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 '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 '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 'Neg2 '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 'Neg1 'Zero +type DAngularMomentum = 'Dim 'Pos2 'Pos1 'Neg1 'Zero 'Zero 'Zero 'Zero 'Neg1 type AngularMomentum = Quantity DAngularMomentum {- @@ -357,7 +357,7 @@ The reciprocal of thermal conductivity. -} -type DThermalResistivity = 'Dim 'Neg1 'Neg1 'Pos3 'Zero 'Pos1 'Zero 'Zero 'Zero 'Zero +type DThermalResistivity = 'Dim 'Neg1 'Neg1 'Pos3 'Zero 'Pos1 'Zero 'Zero 'Zero type ThermalResistivity = Quantity DThermalResistivity {- @@ -366,22 +366,22 @@ Thermal conductance and resistance quantities after http://en.wikipedia.org/wiki -} -type DThermalConductance = 'Dim 'Pos2 'Pos1 'Neg3 'Zero 'Neg1 'Zero 'Zero '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 '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 '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 '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 'Zero 'Zero +type DJerk = 'Dim 'Pos1 'Zero 'Neg3 'Zero 'Zero 'Zero 'Zero 'Zero type Jerk = Quantity DJerk type DAngle = DPlaneAngle -- Abbreviation @@ -390,12 +390,15 @@ type Angle = Quantity DAngle -- Abbreviation type DThrust = DForce type Thrust = Force -type DTorque = 'Dim 'Pos2 'Pos1 'Neg2 'Zero 'Zero 'Zero 'Zero 'Neg1 'Zero +type DTorque = 'Dim 'Pos2 'Pos1 'Neg2 'Zero 'Zero 'Zero 'Zero 'Neg1 type Torque = Quantity DTorque 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 'square' and 'cubic' (see section 9.6 "Spelling unit names raised diff --git a/src/Numeric/Units/Dimensional/DK/SI.hs b/src/Numeric/Units/Dimensional/DK/SI.hs index 5de24901..81ee4af6 100644 --- a/src/Numeric/Units/Dimensional/DK/SI.hs +++ b/src/Numeric/Units/Dimensional/DK/SI.hs @@ -10,7 +10,7 @@ = Summary -This module defines a variant of "Numeric.Units.Dimensional.DK" where plane and solid angles are not treated as dimensions. +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' @@ -19,14 +19,14 @@ module Numeric.Units.Dimensional.DK.SI ( module Numeric.Units.Dimensional.DK, sin, cos, tan, asin, acos, atan, atan2, - DPlaneAngle, DSolidAngle, - PlaneAngle, SolidAngle, + 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, DSolidAngle, PlaneAngle, SolidAngle, baseUnit) +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 @@ -41,10 +41,8 @@ atan2 :: (RealFloat a) => Quantity d a -> Quantity d a -> Dimensionless a atan2 x y = removeAngles $ A.atan2 x y type DPlaneAngle = DOne -type DSolidAngle = DOne type PlaneAngle = Quantity DPlaneAngle -type SolidAngle = Quantity DSolidAngle 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 index 849f077c..17dbc7ab 100644 --- a/src/Numeric/Units/Dimensional/DK/SI/Prelude.hs +++ b/src/Numeric/Units/Dimensional/DK/SI/Prelude.hs @@ -8,7 +8,7 @@ = Summary -This module defines a variant of "Numeric.Units.Dimensional.DK.Prelude" where plane and solid angles are not treated as dimensions. +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 @@ -41,4 +41,5 @@ import Prelude hiding , 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 + ) -- 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 index f61f6e3e..317d11f4 100644 --- a/src/Numeric/Units/Dimensional/DK/SI/Quantities.hs +++ b/src/Numeric/Units/Dimensional/DK/SI/Quantities.hs @@ -12,7 +12,7 @@ = Summary -This module defines a variant of "Numeric.Units.Dimensional.DK.Quantities" where plane and solid angles are not treated as dimensions. +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' @@ -21,15 +21,15 @@ module Numeric.Units.Dimensional.DK.SI.Quantities ( module Numeric.Units.Dimensional.DK.Quantities, - LuminousFlux, Illuminance, AngularVelocity, AngularAcceleration, RadiantIntensity, Radiance, AngularMomentum, Torque, MomentOfInertia, - DLuminousFlux, DIlluminance, DAngularVelocity, DAngularAcceleration, DRadiantIntensity, DRadiance, DAngularMomentum, DTorque, DMomentOfInertia + 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, - DLuminousFlux, DIlluminance, DAngularVelocity, DAngularAcceleration, DRadiantIntensity, DRadiance, DAngularMomentum, DTorque, DMomentOfInertia) +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 @@ -57,3 +57,6 @@ 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 index 3bab7ba6..7e5ac22f 100644 --- a/src/Numeric/Units/Dimensional/DK/SI/SIUnits.hs +++ b/src/Numeric/Units/Dimensional/DK/SI/SIUnits.hs @@ -8,7 +8,7 @@ = Summary -This module defines a variant of "Numeric.Units.Dimensional.DK.SIUnits" where plane and solid angles are not treated as dimensions. +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' From 5f2003409c0ba33f640f818902ed1c241f6c010a Mon Sep 17 00:00:00 2001 From: Douglas McClean Date: Thu, 22 Oct 2015 15:06:30 -0400 Subject: [PATCH 12/12] Converted newtonian mechanics example to work with angles branch. --- examples/NewtonianMechanics.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/NewtonianMechanics.hs b/examples/NewtonianMechanics.hs index 6848ab07..a6312ee6 100644 --- a/examples/NewtonianMechanics.hs +++ b/examples/NewtonianMechanics.hs @@ -33,8 +33,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