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

cats.implicits._ doesn't include Show[Duration] instance #2216

Closed
ceedubs opened this issue Mar 25, 2018 · 7 comments
Closed

cats.implicits._ doesn't include Show[Duration] instance #2216

ceedubs opened this issue Mar 25, 2018 · 7 comments

Comments

@ceedubs
Copy link
Contributor

ceedubs commented Mar 25, 2018

I think that fixing this would involve a binary incompatibility for scala < 2.12, so we probably can't fix this until Cats 2.0.

scala> import cats.Show, cats.implicits._
import cats.Show
import cats.implicits._

scala> Show[scala.concurrent.duration.Duration]
<console>:19: error: could not find implicit value for parameter instance: cats.Show[scala.concurrent.duration.Duration]
       Show[scala.concurrent.duration.Duration]
           ^

scala> import cats.instances.duration._
import cats.instances.duration._

scala> Show[scala.concurrent.duration.Duration]
res1: cats.Show[scala.concurrent.duration.Duration] = cats.Show$$anon$2@2f42b6fc
@peterneyens
Copy link
Collaborator

Not sure, but can we do something for instances like we did for syntax with AllSyntaxBinCompat0 (introduced in #2148)?

@johnynek
Copy link
Contributor

We could possibly violate binary compatibility but not cause a problem in this case.

The problem is when someone subclasses a trait and we add a method. But I assume no one subclasses these traits. They may, but you can imagine weakening our binary compatibility promise in some cases for traits that are what we might say “package sealed” but accessable in other packages.

In fact, this notion of package sealed could be really interesting for other use cases where we only want to prevent subclassing, not access, outside the package.

But then maybe we really just want scala to have a more supported method for adding extension methods without routing them through a heirarchy of traits.

@ceedubs
Copy link
Contributor Author

ceedubs commented Mar 26, 2018

@johnynek in the past I recommended making our instance mix-in traits package-private to ease binary compatibility. However, if I recall correctly, some people didn't want that specifically because they did want to be able to extend the instance mix-in traits. Considering this, we probably shouldn't assume that people aren't subclassing our instance traits.

Binary compatibility becomes much less of an issue for the hierarchy-of-traits approach once we only guarantee backwards compatibility for scala 2.12+ (which it sounds like we may do for Cats 2.0).

I think that we might be able to pull something like what happened in #2148, but I also am not sure whether it's worth the hassle. I haven't seen anyone complain about missing this instance, it's trivial to create if someone wants it, and Show is generally not super helpful. I just happened to notice that it was missing when I was looking at a code coverage report.

@kailuowang
Copy link
Contributor

should be pretty trivial to add it, just let add the cats.instance.DurationInstances to cats.implicits and cats.instances.all. We can't change cats.instance.AllInstances and thus cats.tests.CatsSuite, those would have to wait for cats 2.0

@kubukoz
Copy link
Member

kubukoz commented Apr 15, 2018

If it's OK, I'd like to contribute this (add cats.instances.DurationInstances to cats.implicits and cats.instances.all) :)

@LukaJCB
Copy link
Member

LukaJCB commented Apr 15, 2018

I think before we do that, we need to figure out a branching strategy :)

@kubukoz
Copy link
Member

kubukoz commented Apr 15, 2018

One PR could do that, and a second one (forking the first one's branch) would move these extensions to AllInstances - would that work? The latter would, of course, not be merged until 2.0

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

6 participants