Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve type system #69

Open
zainab-ali opened this issue Apr 25, 2019 · 0 comments
Open

Improve type system #69

zainab-ali opened this issue Apr 25, 2019 · 0 comments

Comments

@zainab-ali
Copy link
Contributor

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 s should be the same quantity as 1 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 convert 1m to 100cm without the need for all the power of a MultiplicativeGroup.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant