-
Notifications
You must be signed in to change notification settings - Fork 23
add implicitly chain for angle conversion factors #52
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| package libra | ||
| package ops | ||
|
|
||
| import libra.UnitOfMeasure | ||
| import libra.nonsi.Angle | ||
| import shapeless.Lazy | ||
| import spire.algebra._ | ||
| import spire.implicits._ | ||
| import spire.math.ConvertableFrom | ||
|
|
||
| object base { | ||
|
|
||
|
|
@@ -32,6 +32,16 @@ object base { | |
| new ConversionFactor(otherConversionFactor.value * value) | ||
| } | ||
|
|
||
| object ConversionFactor { | ||
| implicit def inductiveAngelConversionFactor[A, From <: UnitOfMeasure[Angle], To <: UnitOfMeasure[Angle], Next <: UnitOfMeasure[Angle]]( | ||
|
||
| implicit multiplicativeSemigroup: MultiplicativeSemigroup[A], | ||
| fromConversion: ConversionFactor[A, Angle, From, Next], | ||
| toConversion: Lazy[ConversionFactor[A, Angle, Next, To]] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| ):ConversionFactor[A, Angle, From, To] = | ||
| new ConversionFactor(fromConversion.value * toConversion.value.value) | ||
|
|
||
| } | ||
|
|
||
| /** Derived typeclass for the conversion factor from F to T | ||
| * | ||
| * Two conversions (from and to) are derived from a single conversion factor | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this part be generic on any dimension
Dinstead ofAngle?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i tried but i didn't work (
diverging implicit expansion for type libra.ops.base.ConversionFactor), therefor i usedAngle. I will try one more time to make it more genericThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's ok, there's no need if you already tried! I'll take a better look at it later this week. I've debugged a fair few implicit resolution errors by now, so may have more luck.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so i'm waiting for your solution and i hope that i'll be able to understand them :)