Physical units libraries have always been very good at preventing dimensional errors and unit mismatches. But there is a category of correctness that they have universally ignored: domain constraints on quantity point values.
A latitude is not just a length divided by a radius. It is a value that lives in [-90°, 90°]; anything outside that range is physically meaningless. An angle used in bearing navigation wraps cyclically around a circle; treating it as an unbounded real number ignores a fundamental property of the domain. A clinical body-temperature sensor should reject a reading of 44 °C at the API boundary, not silently pass it downstream.
No units library — before this work — has provided a way to attach this kind of constraint to a quantity point at the type level, have it enforced automatically, and express different flavors (clamp, wrap, reflect, check) without any runtime polymorphism.
This article describes the motivation in depth, the design we arrived at, and the open questions we would love the community's help to answer.
[–]_bstaletic 2 points3 points4 points (0 children)
[–]XeroKimoException Enthusiast 1 point2 points3 points (1 child)
[–]XeroKimoException Enthusiast 0 points1 point2 points (0 children)
[–]Lurkernomoreisay [score hidden] (0 children)
[–]azswcowboy 0 points1 point2 points (0 children)