This library is a result of my experiments with Scala's type system.
The goal I was aiming for when working on this library was to provide units of measurement with following properties:
-
values with units are unboxed (possible thanks to Scala 2.10's custom value classes)
-
units can be defined by user (as opposed to implementations limiting users to seven base SI units)
-
all unit checking should be done on compile time (as opposed to runtime)
-
not a compiler plugin or a macro (although I may add some macro-powered syntactic sugar in the future)
-
proper support for affine spaces
-
easy conversion between units
All of the following implementations were either inefficient or inflexible:
-
- Both outdated and a compiler plugin.
-
- All three above are limited to 7 SI units only, and since they were made before 2.10, values are boxed. They were the direct inspiration for this library.
-
- Allows for adding new units, but all unit checking is performed at runtime, causing a significant runtime overhead.
-
- A source code preprocessor. Converts all units to SI. Does not support arbitrary unit expressions, for example metre to the fourth power would be an invalid unit.