-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Deprecate universal Equiv in Scala 2.13 #7358
Conversation
object PartialOrdering { | ||
implicit def partialOrderingFromOrdering[T](implicit ev: Ordering[T]): PartialOrdering[T] = ev | ||
|
||
@inline def apply[T](implicit ev: PartialOrdering[T]): Equiv[T] = ev |
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 would think this should return PartialOrdering[T]
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.
@inline def apply[T](implicit ev: PartialOrdering[T]): Equiv[T] = ev | |
@inline def apply[T](implicit ev: PartialOrdering[T]): PartialOrdering[T] = ev |
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.
Ugh sloppy copy and paste error. And the universal instance masked the error. I'll fix this and improve the unit tests to make sure that they are resolving the expected instance.
Thank you; good catch.
@@ -58,4 +69,6 @@ object Equiv extends LowPriorityEquiv { | |||
((x, y) => implicitly[Equiv[S]].equiv(f(x), f(y))) | |||
|
|||
@inline def apply[T: Equiv]: Equiv[T] = implicitly[Equiv[T]] | |||
|
|||
implicit def equivFromPartialOrdering[T](implicit ev: PartialOrdering[T]): Equiv[T] = ev |
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.
this is probably going to produce very confusing deprecation messages for Equiv[Float]
and Equiv[Double]
, but don't worry about that. I'll improve it in a follow-up PR. that's not your problem to have to deal with
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.
Looks pretty good to me! Just the one concern about the return type of Equiv.apply
This is a replacement for scala#7187 (see discussion there). This does the following things: 1. Deprecate universal Equiv instance. 2. Create an Ordering -> PartialOrdering conversion. 3. Create a PartialOrdering -> Equiv conversion at a higher priority than the universal instance. 4. Add some unit tests that check that implicit resolution is working as expected. @NthPortal suggested the conversions as a simple way to have `Equiv` instances that could be resolved without duplicating a lot of the work that has been done for `Order` instances for basic types.
f528d2e
to
fe245fb
Compare
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.
LGTM too!
I’d like to run this through the community build before we merge. |
It occurs to me that there should probably be instances for |
@ceedubs I've given up on the idea of a good solution here, and have copied the code from |
Thanks @NthPortal. For the concrete types like Also I apologize in advance, because the next couple of weeks are really busy for me, so I doubt that I'll have time to revisit this PR during that time. |
@ceedubs for the ones that aren't
|
@NthPortal given that @ceedubs says he doesn't have time in the next couple weeks, would you like to continue and submit a fresh PR combining this PR and your branch? |
Thanks so much for all of the help on this, @NthPortal! Sorry that I haven't been more on top of this. |
@ceedubs no worries |
superseded by #7414 |
This is a replacement for #7187 (see discussion there).
This does the following things:
than the universal instance.
expected.
@NthPortal suggested the conversions as a simple way to have
Equiv
instances that could be resolved without duplicating a lot of the work
that has been done for
Order
instances for basic types.