
Am 04.04.2012 13:48, schrieb Jurriƫn Stutterheim:
This sounds pretty cool and useful. How much of this can be implemented in a library and how much of this would need to be supported on a compiler level? Ideally, most of this would be solved on the library level.
The compiler would have to know how to "typecheck" units, e.g. the
addition (+) would combine two values of the same unit, the (/)
operation would divide them:
(+) :: <a> -> <a> -> <a>
(/) :: <a> -> <b> ->
The idea is to have the compiler complain whenever you try to add <b> to
<a> or if you expect something other than as result from a
division. This would require modifications to GHC at compiler level. A
library could offer some basic units (SI units for example) and maybe
even unit aliases ("<N> =