Module

Quantities

Package
purescript-quantities
Repository
sharkdp/purescript-quantities

A helper module which re-exports all sub-modules.

Re-exports from Data.Quantity

#Quantity Source

data Quantity

Representation of a physical quantity as a (product of a) numerical value and a physical unit.

Instances

#ConversionError Source

data ConversionError

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 ConversionError Decimal

Try to convert a quantity to a scalar value

#toScalar Source

toScalar :: Quantity -> Either ConversionError Number

Try to convert a quantity to a scalar value

#sqrt Source

sqrt :: Quantity -> Quantity

The square root of a quantity.

#showResult Source

showResult :: Either ConversionError Quantity -> String

Show the (possibly failed) result of a computation in human-readable form.

#scalar' Source

scalar' :: Decimal -> Quantity

Create a scalar (i.e. dimensionless) quantity from a number.

#scalar Source

scalar :: Number -> Quantity

Create a scalar (i.e. dimensionless) quantity from a number.

#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.

#qSubtract Source

qSubtract :: Quantity -> Quantity -> Either ConversionError Quantity

Attempt to subtract two quantities. If the units can not be unified, an error is returned.

#qNegate Source

qNegate :: Quantity -> Quantity

Negate the numerical value of a quantity.

#qMultiply Source

qMultiply :: Quantity -> Quantity -> Quantity

Multiply two quantities.

#qDivide Source

qDivide :: Quantity -> Quantity -> Quantity

Divide two quantities.

#qAdd Source

qAdd :: Quantity -> Quantity -> Either ConversionError Quantity

Attempt to add two quantities. If the units can not be unified, an error is returned.

#prettyPrint' Source

prettyPrint' :: Quantity -> { number :: String, space :: Boolean, unit :: 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.

#pow Source

pow :: Quantity -> Decimal -> Quantity

Raise a quantity to a given power.

#isFinite Source

isFinite :: Quantity -> Boolean

Check if the numerical value of a quantity is finite.

#fullSimplify Source

fullSimplify :: Quantity -> Quantity

Attempt to simplify the unit of a quantity.

#errorMessage Source

errorMessage :: ConversionError -> 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 ConversionError Quantity

Flipped version of convert.

#convert Source

convert :: DerivedUnit -> Quantity -> Either ConversionError Quantity

Attempt to convert a physical quantity to a given target unit. Returns a ConversionError if the conversion fails.

#asValueIn' Source

asValueIn' :: Quantity -> DerivedUnit -> Either ConversionError Decimal

Get the numerical value of a physical quantity in a given unit. Returns a ConversionError if the conversion fails.

#asValueIn Source

asValueIn :: Quantity -> DerivedUnit -> Either ConversionError Number

Get the numerical value of a physical quantity in a given unit. Returns a ConversionError 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.

#abs Source

abs :: Quantity -> Quantity

The absolute value of a quantity.

#(⊘) Source

Operator alias for Data.Quantity.qDivide (left-associative / precedence 4)

#(⊗) Source

Operator alias for Data.Quantity.qMultiply (left-associative / precedence 4)

#(⊖) Source

Operator alias for Data.Quantity.qSubtract (left-associative / precedence 3)

#(⊕) Source

Operator alias for Data.Quantity.qAdd (left-associative / precedence 3)

#(.*) Source

Operator alias for Data.Quantity.quantity (non-associative / precedence 5)

Re-exports from Data.Quantity.Math

Re-exports from Data.Quantity.Physics

# Source

 :: Quantity

The reduced Planck constant.

#ε0 Source

ε0 :: Quantity

Electric constant (vacuum permittivity).

#α Source

α :: Quantity

Fine structure constant.

#µB Source

µB :: Quantity

Bohr magneton.

#µ0 Source

µ0 :: Quantity

Magnetic constant (vacuum permeability).

#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.

#kB Source

kB :: Quantity

Boltzmann constant.

#idealGasConstant Source

idealGasConstant :: Quantity

Ideal gas constant.

#gravitationalConstant Source

gravitationalConstant :: Quantity

The Newtonian constant of gravitation.

#g0 Source

g0 :: Quantity

Standard gravitational acceleration on earth.

#faradayConstant Source

faradayConstant :: Quantity

Faraday constant.

#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

#Prefix Source

data Prefix

A number that represents a power of ten/two as a prefix for a unit.

Instances

#DerivedUnit Source

newtype 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 or two.

Instances

#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.

#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.

#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

#prefixName Source

prefixName :: Prefix -> Maybe String

Get the name of a SI-prefix.

#power Source

power :: DerivedUnit -> Number -> DerivedUnit

Raise a unit to the given power.

#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.

#divideUnits Source

divideUnits :: DerivedUnit -> DerivedUnit -> DerivedUnit

Divide two units.

#decimalPrefix Source

decimalPrefix :: Number -> DerivedUnit -> DerivedUnit

Add a given decimal prefix value to a unit: withDecimal 3.0 meter = kilo meter.

#binaryPrefix Source

binaryPrefix :: Number -> DerivedUnit -> DerivedUnit

Add a given binary prefix value to a unit: withDecimal 10.0 byte = kibi byte.

#baseRepresentation Source

baseRepresentation :: DerivedUnit -> List DerivedUnit

Return a representation of the DerivedUnit in terms of base units, split by physical dimension.

#(.^) Source

Operator alias for Data.Units.power (left-associative / precedence 9)

#(./) Source

Operator alias for Data.Units.divideUnits (left-associative / precedence 6)

Re-exports from Data.Units.Astronomical

#parsec Source

parsec :: DerivedUnit

Unit of length, 1 parsec = 3.085677581×10^16 m.

#lightyear Source

lightyear :: DerivedUnit

Unit of length, 1 ly = 9460730472580800 m.

Re-exports from Data.Units.Bit

#byte Source

byte :: DerivedUnit

Unit of digital information, 1 byte = 8 bit.

#bit Source

bit :: DerivedUnit

Unit of digital information.

Re-exports from Data.Units.CGS

#gauss Source

gauss :: DerivedUnit

Unit of magnetic flux density, 1 G = 100 µT.

Re-exports from Data.Units.Currency

#euro Source

euro :: DerivedUnit

The official currency of the European Union

#dollar Source

dollar :: DerivedUnit

The United States dollar.

Re-exports from Data.Units.Imperial

#yard Source

yard :: DerivedUnit

Unit of length, 1 yd = 0.9144 m.

#thou Source

thou :: DerivedUnit

Unit of length, 1 thou = 1 thousandth of an inch.

#pound Source

pound :: DerivedUnit

Unit of mass, 1 lb = 453.6 g.

#ounce Source

ounce :: DerivedUnit

Unit of mass, 1 oz = 28.35 g.

#mile Source

mile :: DerivedUnit

Unit of length, 1 mi = 1609.344 m.

#inch Source

inch :: DerivedUnit

Unit of length, 1 in = 0.0254 m.

#furlong Source

furlong :: DerivedUnit

Unit of length, 1 furlong = 201.1680 m.

#foot Source

foot :: DerivedUnit

Unit of length, 1 ft = 0.3048 m.

Re-exports from Data.Units.Misc

#rpm Source

rpm :: DerivedUnit

Unit of frequency, 1 rpm = 1/min.

#psi Source

psi :: DerivedUnit

Unit of pressure, 1 psi = 6.894757 kPa.

#pixel Source

pixel :: DerivedUnit

Smallest addressable element on a digital display.

#piece Source

piece :: DerivedUnit

A separate or limited portion or quantity of something.

#person Source

person :: DerivedUnit

A human being.

#ozf Source

ozf :: DerivedUnit

Unit of force, 1 ozf = 16 lbf.

#molar Source

molar :: DerivedUnit

Unit of molar concentration, 1 molar = 1 mol/L.

#molal Source

molal :: DerivedUnit

Unit of molal concentration, 1 molal = 1 mol/kg.

#mmHg Source

mmHg :: DerivedUnit

Unit of pressure, 1 mmHg = 133.322387415 Pa.

#lbf Source

lbf :: DerivedUnit

Unit of force, 1 lbf = 4.448222 N.

#frame Source

frame :: DerivedUnit

A single image in a (video) sequence.

#fortnight Source

fortnight :: DerivedUnit

Unit of time, 1 fortnight = 2 weeks.

#dot Source

dot :: DerivedUnit

Smallest possible output resolution on a printing device.

#calorie Source

calorie :: DerivedUnit

Unit of energy, 1 cal = 4.184 J.

#btu Source

btu :: DerivedUnit

Unit of energy, 1 BTU = 1055.05585262 J.

#atm Source

atm :: DerivedUnit

Unit of pressure, 1 atm = 101325 Pa.

Re-exports from Data.Units.Nautical

Re-exports from Data.Units.PartsPerX

#percent Source

percent :: DerivedUnit

'Dimensionless' ratio 1 pct = 1e-2.

#partsPerTrillion Source

partsPerTrillion :: DerivedUnit

'Dimensionless' ratio 1 ppt = 1e-12.

#partsPerQuadrillion Source

partsPerQuadrillion :: DerivedUnit

'Dimensionless' ratio 1 ppq = 1e-15.

#partsPerMillion Source

partsPerMillion :: DerivedUnit

'Dimensionless' ratio 1 ppm = 1e-6.

#partsPerBillion Source

partsPerBillion :: DerivedUnit

'Dimensionless' ratio 1 ppb = 1e-9.

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, 1 t = 10³ km.

#liter Source

liter :: DerivedUnit

Unit of volume, 1 L = 1 dm³.

#hectare Source

hectare :: DerivedUnit

Unit of area, 1 ha = 10000 m².

#electronvolt Source

electronvolt :: DerivedUnit

Unit of energy, 1 eV = 1.60217653·10^(−19) J.

#degree Source

degree :: DerivedUnit

'Dimensionless' unit for angles 360 degree = 2·pi rad.

#bel Source

bel :: DerivedUnit

Unit for expressing ratios of two values of a physical quantity.

#barn Source

barn :: DerivedUnit

Unit of area, 1 barn = 10^(-28) m^2.

#bar Source

bar :: DerivedUnit

Unit of pressure, 1 bar = 10^5 Pa.

#astronomicalUnit Source

astronomicalUnit :: DerivedUnit

Unit of length, 1 AU = 1.495978707·10^11 m.

#angstrom Source

angstrom :: DerivedUnit

Unit of length, 1 Å = 10^(-10) m.

Re-exports from Data.Units.SI.Derived

#weber Source

weber :: DerivedUnit

Unit of magnetic flux, 1 Wb = 1 V·s.

#watt Source

watt :: DerivedUnit

Unit of power, 1 W = 1 J/s.

#volt Source

volt :: DerivedUnit

Unit of voltage, 1 V = 1 W/A.

#tesla Source

tesla :: DerivedUnit

Unit of magnetic flux density, 1 T = 1 Wb/m².

#steradian Source

steradian :: DerivedUnit

'Dimensionless' unit for solid angles 1 sr = 1 m²/m².

#sievert Source

sievert :: DerivedUnit

Unit of equivalent dose, 1 Sv = 1 J/kg.

#siemens Source

siemens :: DerivedUnit

Unit of electrical conductance, 1 S = 1 A/V.

#radian Source

radian :: DerivedUnit

'Dimensionless' unit for angles 1 rad = 1 m/m.

#pascal Source

pascal :: DerivedUnit

Unit of pressure, 1 Pa = 1 N/m².

#ohm Source

ohm :: DerivedUnit

Unit of electric resistance, 1 Ω = 1 V/A.

#newton Source

newton :: DerivedUnit

Unit of force, 1 N = 1 kg·m/s².

#lux Source

lux :: DerivedUnit

Unit of illuminance, 1 lx = 1 lm/m².

#lumen Source

lumen :: DerivedUnit

Unit of luminous flux, 1 lm = 1 cd·sr.

#katal Source

katal :: DerivedUnit

Unit of catalytic activity, 1 kat = 1 mol/s.

#joule Source

joule :: DerivedUnit

Unit of energy, 1 J = 1 N·m.

#hertz Source

hertz :: DerivedUnit

Unit of frequency, 1 Hz = 1 / s.

#henry Source

henry :: DerivedUnit

Unit of inductance, 1 H = 1 Wb/A.

#gray Source

gray :: DerivedUnit

Unit of absorbed dose, 1 Gy = 1 J/kg.

#farad Source

farad :: DerivedUnit

Unit of capacitance, 1 F = 1 C/V.

#coulomb Source

coulomb :: DerivedUnit

Unit of electric charge, 1 C = 1 A·s.

#becquerel Source

becquerel :: DerivedUnit

Unit of radioactivity (decays per time), 1 Bq = 1/s.

Re-exports from Data.Units.Time

#year Source

year :: DerivedUnit

Unit of time, 1 year = 365.2425 days (Gregorian year).

#week Source

week :: DerivedUnit

Unit of time, 1 week = 7 days.

#month Source

month :: DerivedUnit

Unit of time, 1 month = 30 days + 10 hours + 29 minutes + 10 seconds.

#minute Source

minute :: DerivedUnit

Unit of time, 1 min = 60 sec.

#julianYear Source

julianYear :: DerivedUnit

Unit of time, 1 julianYear = 365.25 days.

#hour Source

hour :: DerivedUnit

Unit of time, 1 hour = 60 min.

#day Source

day :: DerivedUnit

Unit of time, 1 day = 24 hour.

Re-exports from Data.Units.USCustomary

#teaspoon Source

teaspoon :: DerivedUnit

Unit of volume, the US teaspoon, 1 teaspoon = 1/3·tablespoon.

#tablespoon Source

tablespoon :: DerivedUnit

Unit of volume, the US tablespoon, 1 tablespoon = 1/16·cup.

#rod Source

rod :: DerivedUnit

Unit of length, the US rod, 1 rod = 16.5 ft.

#pint Source

pint :: DerivedUnit

Unit of volume, the US liquid pint, 1 pint = 1/8·gal.

#hogshead Source

hogshead :: DerivedUnit

Unit of volume, the US hogshead, 1 hogshead = 63 gal.

#gallon Source

gallon :: DerivedUnit

Unit of volume, the US liquid gallon, 1 gal = 0.003785411784 m^3 = 231 in^3

#fluidounce Source

fluidounce :: DerivedUnit

Unit of volume, the US fluid ounce, 1 floz = 2 tablespoon.

#cup Source

cup :: DerivedUnit

Unit of volume, the US cup, 1 cup = 1/2·pint.