Skip to content

Add SI, Troy, US Customary unit groups #235

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

Merged
merged 7 commits into from
May 13, 2017
Merged

Conversation

derekmorr
Copy link
Collaborator

This builds on #234 to start adding unit groups.

There are two SI unit groups, "strict" and "expanded." Strict is just those in the SI itself. Expanded adds hours, minutes, days, liters, and other non-SI units that can be used in the SI, as defined in the BIPM appendix.

I defined the SI using implicits to avoid having a massive file with lots of boilerplate calling ... collect SiUnit si ... for each UnitOfMeasure. In order to get UnitGroups implicitly generated, I had to get Dimension into implicit scope, which I did via the ImplicitDimensions object. That's just boilerplate, but at least it's only one per Dimension.

@derekmorr
Copy link
Collaborator Author

i have another commit pending for this that adds the new objects from #227 .

Copy link
Collaborator

@cquiroz cquiroz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really nice. Great work

* Puts [[Dimension]] objects into implicit scope
* so that implicit [[UnitGroup]] machinery works.
*/
object ImplicitDimensions {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a general were question. If we were going to add a new Quantity would there be compilation errors if the implicit Dimension isn't defined here? I hope that's the case 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there wouldn't be. You'll get a compiler error if you try to use it, but this file will build just fine. Which is a problem. I'm not sure the best way to address it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd have the same issue if we wrote lots of boilerplate collecting SiUnit for each Dimension too, though.

@derekmorr derekmorr merged commit 58f2ac5 into master May 13, 2017
@derekmorr derekmorr deleted the unit-groups-si-etc branch May 13, 2017 16:23
@derekmorr derekmorr mentioned this pull request May 18, 2017
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

Successfully merging this pull request may close these issues.

2 participants