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

Ambiguous duration instances #2657

Open
durban opened this Issue Dec 3, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@durban
Contributor

durban commented Dec 3, 2018

The ContravariantShow instances for Duration and FiniteDuration are ambiguous. Thus, it is not possible to summon a ContravariantShow[FiniteDuration]. This also makes FiniteDuration unusable with the show"..." string interpolation.

[error] ....scala:10:13: ambiguous implicit values:
[error]  both value catsStdShowForDuration in trait DurationInstances of type => cats.Show[scala.concurrent.duration.Duration]
[error]  and value catsStdShowForFiniteDuration in trait FiniteDurationInstances of type => cats.Show[scala.concurrent.duration.FiniteDuration]
[error]  match expected type cats.Show.ContravariantShow[scala.concurrent.duration.FiniteDuration]
[error]   implicitly[cats.Show.ContravariantShow[FiniteDuration]]
[error]             ^

@LukaJCB LukaJCB added the bug label Dec 3, 2018

@kailuowang

This comment has been minimized.

Member

kailuowang commented Dec 6, 2018

yeah, this is tricky. We wanted show"..." to work when Show instance of supertype is available, but obviously, the variance is causing trouble when instances for both parent and child are defined.
One solution I can think of is that we add a new show_"..." that only takes Show.

@ceedubs

This comment has been minimized.

Member

ceedubs commented Dec 10, 2018

It might be tricky to do in binary-compatible way (although I think that it might be able to be done), but one possible solution is to put the Duration and FiniteDuration instances into the same trait so that we can prioritize the two instances.

@kailuowang

This comment has been minimized.

Member

kailuowang commented Dec 11, 2018

@ceedubs I think it's worth a try. and it should be easy to keep BC by just removing the implicit from old ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment