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

ambiguous implicit resolution of Show.ContravariantShow[immutable.SortedMap[K, V]] #4574

Closed
chwthewke opened this issue Mar 15, 2024 · 1 comment · Fixed by #4575
Closed

Comments

@chwthewke
Copy link
Contributor

In the following code:

object ShowIssue {

  val ok = Show[SortedMap[Int, String]]
  val ko = implicitly[Show.ContravariantShow[SortedMap[Int, String]]]

}

the line val ko = ... fails to compile with:

ambiguous implicit values:
both method catsShowForMap in object Show of type [K, V](implicit evidence$9: cats.Show[K], evidence$10: cats.Show[V]): cats.Show[Map[K,V]]
and method catsShowForSortedMap in object Show of type [K, V](implicit evidence$12: cats.Show[K], evidence$13: cats.Show[V]): cats.Show[scala.collection.immutable.SortedMap[K,V]]
match expected type cats.Show.ContravariantShow[scala.collection.immutable.SortedMap[Int,String]]
val ko = implicitly[Show.ContravariantShow[SortedMap[Int, String]]]

This is rarely an issue in practice (just use the Show instance), except when a library attempts to specifically summon a ContravariantShow instance, such as kittens apparently does (since 3.1.0 I believe)

Seen with cats-core 2.10.0, under Scala 2.13.13

Thank you for your consideration

@chwthewke
Copy link
Contributor Author

Oh, I was afraid to even look at how this might be fixable (because implicit priority problems are scaaary), but it seems it was easy and I made a PR #4575

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

Successfully merging a pull request may close this issue.

1 participant