Data.Units
- Package
- purescript-quantities
- Repository
- sharkdp/purescript-quantities
This module defines data types and functions to handle physical units.
#DerivedUnit Source
data DerivedUnitA generic physical unit. The Semigroup/Monoid instance implements
multiplication of units.
Implementation detail:
A DerivedUnit is a product of BaseUnits, raised to arbitrary powers.
Each factor also has a Prefix value which represents a numerical
prefix as a power of ten or two.
Instances
#decimalPrefix Source
decimalPrefix :: Number -> DerivedUnit -> DerivedUnitAdd a given decimal prefix value to a unit: withDecimal 3.0 meter = kilo meter.
#binaryPrefix Source
binaryPrefix :: Number -> DerivedUnit -> DerivedUnitAdd a given binary prefix value to a unit: withDecimal 10.0 byte = kibi byte.
#removePrefix Source
removePrefix :: DerivedUnit -> DerivedUnitRemove all prefix values from the unit:
removePrefix (kilo meter <> milli second) = meter <> second
#simplify Source
simplify :: DerivedUnit -> DerivedUnitSimplify the internal representation of a DerivedUnit by merging base
units of the same type. For example, m·s·m will by simplified to m²·s.
#splitByDimension Source
splitByDimension :: DerivedUnit -> List (Tuple DerivedUnit DerivedUnit)Split up a physical unit into several parts that belong to the same physical dimension (length, time, ...). In the first component, the returned tuples contain a 'target' unit, to which this group can be converted. In the second component, the original group is returned.
#baseRepresentation Source
baseRepresentation :: DerivedUnit -> List DerivedUnitReturn a representation of the DerivedUnit in terms of base units, split
by physical dimension.
#makeStandard Source
makeStandard :: String -> String -> DerivedUnitHelper function to create a standard unit.
#makeNonStandard Source
makeNonStandard :: String -> String -> Number -> DerivedUnit -> DerivedUnitHelper function to create a non-standard unit.
#toStandardUnit Source
toStandardUnit :: DerivedUnit -> Tuple DerivedUnit ConversionFactorConvert all contained units to standard units and return the global conversion factor.
#toString Source
toString :: DerivedUnit -> StringA human-readable String representation of a DerivedUnit.
#power Source
power :: DerivedUnit -> Number -> DerivedUnitRaise a unit to the given power.
#divideUnits Source
divideUnits :: DerivedUnit -> DerivedUnit -> DerivedUnitDivide two units.
#unity Source
unity :: DerivedUnitA DerivedUnit corresponding to 1, i.e. the unit of scalar
(or dimensionless) values.
#atto Source
atto :: DerivedUnit -> DerivedUnit#femto Source
femto :: DerivedUnit -> DerivedUnit#pico Source
pico :: DerivedUnit -> DerivedUnit#nano Source
nano :: DerivedUnit -> DerivedUnit#micro Source
micro :: DerivedUnit -> DerivedUnit#centi Source
centi :: DerivedUnit -> DerivedUnit#deci Source
deci :: DerivedUnit -> DerivedUnit#hecto Source
hecto :: DerivedUnit -> DerivedUnit#milli Source
milli :: DerivedUnit -> DerivedUnit#kilo Source
kilo :: DerivedUnit -> DerivedUnit#mega Source
mega :: DerivedUnit -> DerivedUnit#giga Source
giga :: DerivedUnit -> DerivedUnit#tera Source
tera :: DerivedUnit -> DerivedUnit#peta Source
peta :: DerivedUnit -> DerivedUnit#exa Source
exa :: DerivedUnit -> DerivedUnit#kibi Source
kibi :: DerivedUnit -> DerivedUnit#mebi Source
mebi :: DerivedUnit -> DerivedUnit#gibi Source
gibi :: DerivedUnit -> DerivedUnit#tebi Source
tebi :: DerivedUnit -> DerivedUnit#pebi Source
pebi :: DerivedUnit -> DerivedUnit#exbi Source
exbi :: DerivedUnit -> DerivedUnit#zebi Source
zebi :: DerivedUnit -> DerivedUnit#yobi Source
yobi :: DerivedUnit -> DerivedUnit- Modules
- Data.
Quantity - Data.
Quantity. Math - Data.
Quantity. Physics - Data.
Units - Data.
Units. Astronomical - Data.
Units. Bit - Data.
Units. CGS - Data.
Units. Currency - Data.
Units. Imperial - Data.
Units. Misc - Data.
Units. Nautical - Data.
Units. PartsPerX - Data.
Units. SI - Data.
Units. SI. Accepted - Data.
Units. SI. Derived - Data.
Units. Time - Data.
Units. USCustomary - Quantities