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

Implicitly chain conversion factors #50

Open
zainab-ali opened this issue Nov 29, 2017 · 1 comment
Open

Implicitly chain conversion factors #50

zainab-ali opened this issue Nov 29, 2017 · 1 comment
Milestone

Comments

@zainab-ali
Copy link
Contributor

Given an implicit ConversionFactor[P, Q, A, B] and a ConversionFactor[P, Q, B, C], create a ConversionFactor[P, Q, A, C].

Where there are multiple units for a single dimension, conversion factors need to be defined between each pair individually. This means that there's a matrix of implicit conversion factors that need to be written. E.g. for degree, arcsecond and arcminute, conversion factors need to be written for arcsecond - arcminute, arcminute - degree and arcsecond - degree.

It should technically be possible to implicitly derive the arcsecond - degree conversion using the previous two. This would remove a lot of boilerplate when adding new units.

The following implicit fails to resolve:

implicit def failedAttemptAtChaining[P, Q, A, B](implicit ab: ConversionFactor[P, Q, A, B], bc: ConversionFactor[P, Q, B, C]): ConversionFactor[P, Q, A, C] = ???

This is probably because the compiler cannot resolve B, as it only knows A and C.

@ldrygala
Copy link
Contributor

Hi @zainab-ali i'm working on it.

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

2 participants