Q package:dimensional

A dimensionless number with n fractional bits, using a representation of type a.
A dimensional quantity.
A binary scale factor.

Summary

This module defines type synonyms for common dimensionalities and the associated quantity types. Additional dimensionalities and quantity types will be added on an as-needed basis. The definitions in this module are grouped so that a type synonym for the dimensionality is defined first in terms of base dimension exponents. Then a type synonym for the corresponding quantity type is defined. If there are several quantity types with the same dimensionality, type synonyms are provided for each quantity type.

References

  1. https://www.nist.gov/pml/special-publication-811
integer division truncated toward zero WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.
simultaneous quot and rem WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.
The "quecto" prefix, denoting a factor of 10^-30.
The "quetta" prefix, denoting a factor of 10^30.
Square root is a special case of NRoot with order 2.
Forms a new atomic Unit by specifying its UnitName and its definition as a multiple of another Unit. Use this variant when the scale factor of the resulting unit is rational. See mkUnitZ for when it is an integer and mkUnitR for the general case. For more information see mkUnitR.
Computes the square root of a Quantity using **. The NRoot type family will prevent application where the supplied quantity does not have a square dimension.
(x :: Area Double) >= _0 ==> sqrt x == nroot pos2 x
Unwraps a possibly-scaled SQuantity, yielding its underlying representation. This is a type-restricted version of coerce.
Takes the square root of a dimension, if it exists.
sqrt d == nroot 2 d
A Quantity whose Dimension is only known dynamically.
Possibly a Quantity whose Dimension is only known dynamically. By modeling the absence of a value, this type differs from AnyQuantity in that it may not be a Quantity of any Dimension whatsoever, but in exchange it gains instances for the common numeric classes. It's therefore useful for manipulating, and not merely storing, quantities of unknown dimension. This type also contains a polydimensionalZero, representing zero value of any dimension. Note that the Eq instance for DynQuantity equates all representations of an invalid value, and also does not equate polydimensional zero with zero of any specific dimension.
Forgets information about a Quantity or AnyQuantity, yielding an AnyQuantity or a DynQuantity.
A DynQuantity which does not correspond to a value of any dimension.
Converts a dynamic quantity such as an AnyQuantity or a DynQuantity into a Quantity, or to Nothing if the dynamic quantity cannot be represented in the narrower result type.
A dimensional quantity, stored as an ExactPi' multiple of its value in its dimension's SI coherent unit. The name is an abbreviation for scaled quantity.
One imperial quart is one quarter of an imperialGallon. See here for further information.
>>> 1 *~ imperialQuart
1.1365225e-3 m^3
>>> 1 *~ imperialQuart :: Volume Rational
454609 % 400000000 m^3
One US liquid quart is one quarter of a usGallon. See here for further information.
>>> 1 *~ usQuart
9.46352946e-4 m^3
>>> 1 *~ usQuart :: Volume Rational
473176473 % 500000000000 m^3
The Eq class defines equality (==) and inequality (/=). All the basic datatypes exported by the Prelude are instances of Eq, and Eq may be derived for any datatype whose constituents are also instances of Eq. The Haskell Report defines no laws for Eq. However, instances are encouraged to follow these properties:
  • Reflexivity x == x = True
  • Symmetry x == y = y == x
  • Transitivity if x == y && y == z = True, then x == z = True
  • Extensionality if x == y = True and f is a function whose return type is an instance of Eq, then f x == f y = True
  • Negation x /= y = not (x == y)
Minimal complete definition: either == or /=.