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

Conflicting ContravariantShow for ZoneOffset #55

Open
nigredo-tori opened this issue Mar 15, 2019 · 1 comment
Open

Conflicting ContravariantShow for ZoneOffset #55

nigredo-tori opened this issue Mar 15, 2019 · 1 comment

Comments

@nigredo-tori
Copy link
Contributor

It seems my instances for ZoneId and ZoneOffset are slightly broken. When importing io.chrisdavenport.cats.time.instances.all._, I get a conflict when trying to show a ZoneOffset:

scala> show"${ZoneOffset.UTC}"
<console>:22: error: type mismatch;
 found   : java.time.ZoneOffset
 required: cats.Show.Shown
       show"${ZoneOffset.UTC}"
                         ^

This arises because there are two overlapping instances for ContravariantShow[-T]:

scala> Show.Shown.mat(ZoneOffset.UTC)
<console>:22: error: ambiguous implicit values:
 both value zoneidInstances in trait zoneid of type => cats.Show[java.time.ZoneId] with cats.Eq[java.time.ZoneId] with cats.Hash[java.time.ZoneId]
 and value zoneoffsetInstances in trait zoneoffset of type => cats.Show[java.time.ZoneOffset] with cats.Order[java.time.ZoneOffset] with cats.Hash[java.time.ZoneOffset]
 match expected type cats.Show.ContravariantShow[java.time.ZoneOffset]
       Show.Shown.mat(ZoneOffset.UTC)
                     ^

, and the compiler can't choose a better one.

I'm not sure what would be the best course of action here. Removing Show[ZoneOffset] would fix interpolation, however most of generic code I've seen relies directly on Show!

@nigredo-tori
Copy link
Contributor Author

There is a similar known issue in typelevel/cats: typelevel/cats#2657

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

1 participant