-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Libra was developed as an approach for inductively modeling dimensional analysis. It wasn't based on prior research in the field, and so fell into many common pitfalls associated with modeling dimensions. Notably:
- comparisons between quantities of the same dimensions, but differently ordered hlists.
1 kg sshould be the same quantity as1 s kg. While we attempt to achieve this in our typeclasses, it isn't the case at the type level, so implicit searches that depend on this equivalence fail - some units of the same dimension have an offset, e.g. Celsius vs Fahrenheit. Libra fails to model these entirely
- some units do not scale linearly e.g. decibels. Libra also fails to model these.
- the conversions are inexact. Libra only supports conversions between quantities with a
MultiplicativeGroup, but this isn't always entirely necessary. It should be possible to convert1mto100cmwithout the need for all the power of aMultiplicativeGroup.
The following technical report on developing a type system for dimensional analysis contains a wealth of information regarding dimensions and their type inference. Some of it's suggestions could be taken forward to solve some of the problems listed above.
One suggestion is the use of a normal form of dimension lists to enable equality between differently ordered lists. This could be modeled using a typeclass for a total order of all dimensions and units used in a project. If each dimension and unit has a show, this could potentially be derived using string ordering.