kex docs Standard Library

Units.Dynamic

module Units.Dynamic

Runtime dimensional quantities. Unit dimensions use nominal Type identities, and all arithmetic composes the same normalized exponent maps.

unit

unit(scale: Float, dimension: Dimension, notation: String) -> Result<DynamicUnit, UnitError>

Define a positive, finite scale to the dimension's canonical unit.

measure

measure(value: Float, unit: DynamicUnit) -> DynamicMeasure

Build a quantity in its preferred display unit.

record DynamicUnit

Fields

scale
Float
dimension
Dimension
notation
String

Functions

*

*(other: DynamicUnit) -> Result<DynamicUnit, UnitError>

Preserve grouping in display expressions as well as dimensions and scale.

pow

pow(exponent: Integer) -> Result<DynamicUnit, UnitError>

named

named(notation: String) -> DynamicUnit

scaled

scaled(factor: Float, notation: String) -> Result<DynamicUnit, UnitError>

record DynamicMeasure

Fields

canonical
Float

Functions

value

value : Float

Display magnitude is derived, never a second independently stored value.

pow

pow(exponent: Integer) -> Result<DynamicMeasure, UnitError>

scale

scale(factor: Float) -> DynamicMeasure

compareTo

compareTo(other: DynamicMeasure) -> Result<Ordering, UnitError>

Ordering ignores display preferences but requires compatible dimensions.

type UnitError

Variants

  • InvalidScale(Float)
  • ScaleOverflow
  • DimensionMismatch(Dimension, Dimension)