HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduledimensional-1.5Haskell2010

Numeric.Units.Dimensional.Dynamic

Defines types for manipulation of units and quantities without phantom types for their dimensions.

  • 4 types
  • 3 classes
  • 16 values
  • Packagedimensional-1.5
  • Exports23
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceDynamic.hs

Dynamic Quantities

12 declarations
datadata AnyQuantity a
#

A Quantity whose Dimension is only known dynamically.

Instances14Demotable, Promotable, Generic1, Eq, Data, Show, …
datadata DynQuantity a
#

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.

Instances15Promotable, Generic1, Eq, Floating, Fractional, Data, …
classclass HasDynamicDimension a where
#

Dimensional values, or those that are only possibly dimensional, inhabit this class, which allows access to a term-level representation of their dimension.

Methods

Instances7HasDynamicDimension, …
datadata DynamicDimension
#

The dimension of a dynamic value, which may not have any dimension at all.

Constructors

Instances8Eq, Data, Ord, Show, Generic, NFData, …
value(/~) :: (Floating a, Promotable q) => q a -> AnyUnit -> Maybe a
#

Divides a dynamic quantity by a dynamic unit, obtaining the numerical value of the quantity expressed in that unit if they are of the same physical dimension, or Nothing otherwise.

A DynQuantity which corresponds to zero value of any dimension.

When combined through arithmetic with other DynQuantitys, inference is performed. For example, adding a length to polydimensional zero produces that length. Adding two polydimensional zeros produces another. Taking the sine of a polydimensional zero interprets it as a dimensionless zero and produces a dimensionless result.

Note that division by polydimensionalZero produces a polydimensional result, which may be an error or some representation of infinity, as determined by the underlying arithmetic type. This behavior was chosen for consistency with the behavior of division by zero DynQuantitys of a specific dimension.

Dynamic Units

6 declarations
datadata AnyUnit
#

A Unit whose Dimension is only known dynamically.

Instances8Show, Generic, Semigroup, Monoid, HasDimension, HasDynamicDimension, …

Arithmetic on Dynamic Units