[racket] Numbers with dimensions

From: Konrad Hinsen (konrad.hinsen at fastmail.net)
Date: Sat Oct 26 12:42:33 EDT 2013

Laurent writes:

 > Examples and details here:
 > https://github.com/Metaxal/measures

At first glance, I miss the notion of "dimension", which defines if
two units are compatible, i.e. can be converted. If I understand your
approach correctly (which I am not sure about), you consider each
product of unit symbols as distinct. That means if someone enters a
pressure in Pascal, and multiplies by an area in square meters, the
result cannot be added to a force in Newton, although a Pascal is by
definition a Newton per square meter.

BTW, I can offer my Clojure units library for inspiration, if someone
wants to implement a straightforward approach based on run-time checks:

  http://code.google.com/p/clj-units/

It deals with dimension compatibility, and allows the definition of
any number of unit systems. Like pretty much any library I know of, it
doesn't handle the particularity of the SI system of having distinct
incompatible units with equal dimension, such as Bq (Bequerel) and Hz
(Hertz), which are both 1/s but reserved for specific applications.
My library will let you convert Hz to Bq without complaint.

Konrad.

Posted on the users mailing list.