Quantities
- Package
- purescript-quantities
- Repository
- sharkdp/purescript-quantities
A helper module which re-exports all sub-modules.
Re-exports from Data.Quantity
#UnificationError Source
data UnificationError
A unit conversion error that appears if two given units cannot be converted into each other.
Constructors
Instances
#toStandard Source
toStandard :: Quantity -> Quantity
Convert a quantity to its standard representation.
#toScalar' Source
toScalar' :: Quantity -> Either UnificationError Decimal
Try to convert a quantity to a scalar value
#toScalar Source
toScalar :: Quantity -> Either UnificationError Number
Try to convert a quantity to a scalar value
#showResult Source
showResult :: Either UnificationError Quantity -> String
Show the (possibly failed) result of a computation in human-readable form.
#quantity' Source
quantity' :: Decimal -> DerivedUnit -> Quantity
Construct a physical quantity from a numerical value and the physical unit.
#quantity Source
quantity :: Number -> DerivedUnit -> Quantity
Construct a physical quantity from a numerical value and the physical unit.
#prettyPrint' Source
prettyPrint' :: Quantity -> Tuple String String
Show a physical quantity in a human-readable form, value and unit separately.
#prettyPrint Source
prettyPrint :: Quantity -> String
Show a physical quantity in a human-readable form.
#fullSimplify Source
fullSimplify :: Quantity -> Quantity
Attempt to simplify the unit of a quantity.
#errorMessage Source
errorMessage :: UnificationError -> String
Textual representation of a unit conversion error.
#derivedUnit Source
derivedUnit :: Quantity -> DerivedUnit
The unit of a physical quantity.
#convertTo Source
convertTo :: Quantity -> DerivedUnit -> Either UnificationError Quantity
Flipped version of convert
.
#convert Source
convert :: DerivedUnit -> Quantity -> Either UnificationError Quantity
Attempt to convert a physical quantity to a given target unit. Returns a
UnificationError
if the conversion fails.
#asValueIn' Source
asValueIn' :: Quantity -> DerivedUnit -> Either UnificationError Decimal
Get the numerical value of a physical quantity in a given unit. Returns a
UnificationError
if the conversion fails.
#asValueIn Source
asValueIn :: Quantity -> DerivedUnit -> Either UnificationError Number
Get the numerical value of a physical quantity in a given unit. Returns a
UnificationError
if the conversion fails.
#approximatelyEqual Source
approximatelyEqual :: Number -> Quantity -> Quantity -> Boolean
Check whether two quantities have matching units (or can be converted to the same representation) and test if the numerical values are approximately equal.
Re-exports from Data.Quantity.Math
Re-exports from Data.Quantity.Physics
#speedOfLight Source
speedOfLight :: Quantity
The speed of light in vacuum.
#protonMass Source
protonMass :: Quantity
Mass of the proton.
#planckConstant Source
planckConstant :: Quantity
The Planck constant.
#gravitationalConstant Source
gravitationalConstant :: Quantity
The Newtonian constant of gravitation.
#electronMass Source
electronMass :: Quantity
The mass of the electron.
#electronCharge Source
electronCharge :: Quantity
Elementary charge (charge of the electron).
#avogadroConstant Source
avogadroConstant :: Quantity
Avogadro's number.
Re-exports from Data.Units
#DerivedUnit Source
data DerivedUnit
A 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.
Instances
#withPrefix Source
withPrefix :: Number -> DerivedUnit -> DerivedUnit
Add a given prefix value to a unit: withPrefix 3.0 meter = kilo meter
.
#unity Source
unity :: DerivedUnit
A DerivedUnit
corresponding to 1
, i.e. the unit of scalar
(or dimensionless) values.
#toString Source
toString :: DerivedUnit -> String
A human-readable String
representation of a DerivedUnit
.
#toStandardUnit Source
toStandardUnit :: DerivedUnit -> Tuple DerivedUnit ConversionFactor
Convert all contained units to standard units and return the global conversion factor.
#tera Source
tera :: DerivedUnit -> DerivedUnit
#splitByDimension Source
splitByDimension :: DerivedUnit -> List (Tuple DerivedUnit DerivedUnit)
Split up a physical units 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.
#simplify Source
simplify :: DerivedUnit -> DerivedUnit
Simplify 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.
#removePrefix Source
removePrefix :: DerivedUnit -> DerivedUnit
Remove all prefix values from the unit:
removePrefix (kilo meter <> milli second) = meter <> second
#power Source
power :: DerivedUnit -> Number -> DerivedUnit
Raise a unit to the given power.
#pico Source
pico :: DerivedUnit -> DerivedUnit
#peta Source
peta :: DerivedUnit -> DerivedUnit
#nano Source
nano :: DerivedUnit -> DerivedUnit
#milli Source
milli :: DerivedUnit -> DerivedUnit
#micro Source
micro :: DerivedUnit -> DerivedUnit
#mega Source
mega :: DerivedUnit -> DerivedUnit
#makeStandard Source
makeStandard :: String -> String -> DerivedUnit
Helper function to create a standard unit.
#makeNonStandard Source
makeNonStandard :: String -> String -> Number -> DerivedUnit -> DerivedUnit
Helper function to create a non-standard unit.
#kilo Source
kilo :: DerivedUnit -> DerivedUnit
#hecto Source
hecto :: DerivedUnit -> DerivedUnit
#giga Source
giga :: DerivedUnit -> DerivedUnit
#femto Source
femto :: DerivedUnit -> DerivedUnit
#exa Source
exa :: DerivedUnit -> DerivedUnit
#divideUnits Source
divideUnits :: DerivedUnit -> DerivedUnit -> DerivedUnit
Divide two units.
#deci Source
deci :: DerivedUnit -> DerivedUnit
#centi Source
centi :: DerivedUnit -> DerivedUnit
#baseRepresentation Source
baseRepresentation :: DerivedUnit -> List DerivedUnit
Return a representation of the DerivedUnit
in terms of base units, split
by physical dimension.
#atto Source
atto :: DerivedUnit -> DerivedUnit
Re-exports from Data.Units.Bit
#byte Source
byte :: DerivedUnit
Unit of digital information, 1byte = 8bit.
#bit Source
bit :: DerivedUnit
Unit of digital information.
Re-exports from Data.Units.Imperial
#yard Source
yard :: DerivedUnit
Unit of length, 1yd = 0.9144m.
#pound Source
pound :: DerivedUnit
Unit of mass, 1lb = 453.6g.
#ounce Source
ounce :: DerivedUnit
Unit of mass, 1oz = 28.35g.
#mile Source
mile :: DerivedUnit
Unit of length, 1mi = 1609.344m.
#inch Source
inch :: DerivedUnit
Unit of length, 1in = 0.0254m.
#foot Source
foot :: DerivedUnit
Unit of length, 1ft = 0.3048m.
Re-exports from Data.Units.SI
#second Source
second :: DerivedUnit
The second is the standard unit of time.
#mole Source
mole :: DerivedUnit
The mole is the standard unit for amount of substance.
#meter Source
meter :: DerivedUnit
The meter is the standard unit of length.
#kilogram Source
kilogram :: DerivedUnit
The kilogram is the standard unit of mass.
#kelvin Source
kelvin :: DerivedUnit
The kelvin is the standard unit of temperature.
#gram Source
gram :: DerivedUnit
One gram equals one-thousandth of a kilogram.
#candela Source
candela :: DerivedUnit
The candela is the standard unit of luminous intensity.
#ampere Source
ampere :: DerivedUnit
The ampere is the standard unit of electric current.
Re-exports from Data.Units.SI.Accepted
#tonne Source
tonne :: DerivedUnit
Unit of mass, 1t = 10³ km.
#liter Source
liter :: DerivedUnit
Unit of volume, 1L = 1dm³.
#hectare Source
hectare :: DerivedUnit
Unit of area, 1ha = 10000m².
#electronvolt Source
electronvolt :: DerivedUnit
Unit of energy, 1eV = 1.60217653·10^(−19) J.
#degree Source
degree :: DerivedUnit
'Dimensionless' unit for angles 360 degree = 2 pi rad.
Re-exports from Data.Units.SI.Derived
#weber Source
weber :: DerivedUnit
Unit of magnetic flux, 1Wb = 1V·s.
#watt Source
watt :: DerivedUnit
Unit of power, 1W = 1J/s.
#volt Source
volt :: DerivedUnit
Unit of voltage, 1V = 1W/A.
#tesla Source
tesla :: DerivedUnit
Unit of magnetic flux density, 1T = 1Wb/m².
#steradian Source
steradian :: DerivedUnit
'Dimensionless' unit for solid angles 1 sr = 1m² / 1m².
#sievert Source
sievert :: DerivedUnit
Unit of equivalent dose, 1Sv = 1J/kg.
#siemens Source
siemens :: DerivedUnit
Unit of electrical conductance, 1S = 1A/V.
#radian Source
radian :: DerivedUnit
'Dimensionless' unit for angles 1 rad = 1m / 1m.
#pascal Source
pascal :: DerivedUnit
Unit of pressure, 1Pa = 1N/m².
#ohm Source
ohm :: DerivedUnit
Unit of electric resistance, 1Ω = 1V/A.
#newton Source
newton :: DerivedUnit
Unit of force, 1N = 1kg⋅m/s².
#lux Source
lux :: DerivedUnit
Unit of illuminance, 1lx = 1lm/m².
#lumen Source
lumen :: DerivedUnit
Unit of luminous flux, 1lm = 1cd·sr.
#katal Source
katal :: DerivedUnit
Unit of catalytic activity, 1kat = 1mol/s.
#joule Source
joule :: DerivedUnit
Unit of energy, 1J = 1N·m.
#hertz Source
hertz :: DerivedUnit
Unit of frequency, 1 Hz = 1 / s.
#henry Source
henry :: DerivedUnit
Unit of inductance, 1H = 1Wb/A.
#gray Source
gray :: DerivedUnit
Unit of absorbed dose, 1Gy = 1J/kg.
#farad Source
farad :: DerivedUnit
Unit of capacitance, 1F = 1C/V.
#coulomb Source
coulomb :: DerivedUnit
Unit of electric charge, 1C = 1A·s.
#becquerel Source
becquerel :: DerivedUnit
Unit of radioactivity (decays per time), 1Bq = 1/s.
Re-exports from Data.Units.Time
#year Source
year :: DerivedUnit
Unit of time, 1year = 365days.
#week Source
week :: DerivedUnit
Unit of time, 1week = 7days.
#month Source
month :: DerivedUnit
Unit of time, 1month = 30days + 10hours.
#minute Source
minute :: DerivedUnit
Unit of time, 1min = 60sec.
#hour Source
hour :: DerivedUnit
Unit of time, 1hour = 60min.
#day Source
day :: DerivedUnit
Unit of time, 1day = 24hour.
Re-exports from Data.Units.USCustomary
#teaspoon Source
teaspoon :: DerivedUnit
Unit of Volume, the US teaspoon, 1teaspoon = 1/3·tablespoon.
#tablespoon Source
tablespoon :: DerivedUnit
Unit of Volume, the US tablespoon, 1tablespoon = 1/16·cup.
#pint Source
pint :: DerivedUnit
Unit of Volume, the US liquid pint, 1pint = 1/8·gal.
#gallon Source
gallon :: DerivedUnit
Unit of Volume, the US liquid gallon, 1gal = 0.003785411784m^3 = 231in^3
#cup Source
cup :: DerivedUnit
Unit of Volume, the US cup, 1cup = 1/2·pint.