-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Contravariant typeclasses and specificity for Nothing
were not yet good enough for ourselves?
#4465
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
Comments
/cc @alexknvl @OlivierBlanvillain |
Still same behavior after merging #4329. |
OTOH, either before or after #4329 and with or without scala> implicitly[Show[List[Nothing]]].instName
val res2: String = showList
scala> implicitly[Show[Option[Nothing]]].instName
val res3: String = showOption
scala> def show[T: Show](t: T) = implicitly[Show[T]].show(t)
def show[T](t: T)(implicit evidence$1: Show[T]): String
scala> show(List())
val res4: String = showList
scala> show(None)
val res1: String = showOption
scala> show(Some(1))
val res2: String = showOption
scala> show(Nil)
val res3: String = showList
scala> show(1 :: Nil)
val res4: String = showList |
Nothing
are not yet good enough for ourselvesNothing
were not yet good enough for ourselves?
New plan: ensure all of this is sufficiently tested, and cross-check with Scalac tests. |
So what are we missing here? A spec for the current behavior? I'm not sure where would be the best place to put that, but the comment in |
I wanted to get back to this, but I'm not sure there is a real problem any more (per #4465 (comment)). In doubt, I should probably close this — feel free to reopen and reassign. |
Uh oh!
There was an error while loading. Please reload this page.
Apparently, for contravariant typeclasses, an instance for
Nothing
is ambiguous with instances forList[T]
andOption[T]
. That blocks instance resolution for something as simple asList()
.I'm not sure whether this is an issue with the spec or with the implementation; I suppose this was an oversight. But it's enough to make instance resolution for
Show
unusable for us, so much that in #4437 people are proposing to dropShow
altogether (also for unrelated reasons). Here's the puzzler:Any
, regardless that it's maybe less of a problemThe text was updated successfully, but these errors were encountered: