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._ -> cats.syntax.all._ #4394

Conversation

armanbilge
Copy link
Member

It's about damn time!

johnynek
johnynek previously approved these changes Feb 6, 2023
satorg
satorg previously approved these changes Feb 6, 2023
Copy link
Contributor

@satorg satorg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you 👍

@armanbilge armanbilge dismissed stale reviews from satorg and johnynek via d05ed4b February 6, 2023 21:46
Comment on lines 24 to 25
import cats.instances.all._
import cats.syntax.all._
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. That looks quite odd. As I understand, these two imports should not be required to happen simultaneously. So if they are required then perhaps some implicits are missing from the cats.syntax.all._ path.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if they are required then perhaps some implicits are missing from the

No, odd but correct. How can you resolve this implicit with only the syntax import?

cats.Monad[cats.data.OptionT[List, *]],

The syntax imports only work if you use the syntax :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... Not sure, what do you mean. This particular example does not require any additional imports to compile.
Because Monad for OptionT is picked up from the OptionT's companion, apparently.
Whereas Monad[List] is picked up from the Invariant's companion automatically:

implicit def catsInstancesForList: Monad[List] with Alternative[List] with CoflatMap[List] =
cats.instances.list.catsStdInstancesForList

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, I don't think it is an obstacle to get this PR merged :) Thank you for cleaning the imports up!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh hm maybe I said a stupid :) and I was so sure I had it all figured out! let me take one more look at this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh 🤦 it's because the whole point of this file, it to compile it against Cats v2.0.0, which pre-dates the re-organization that puts all implicits automatically in scope.

cats/build.sbt

Lines 265 to 271 in ccd576f

lazy val binCompatTest = project
.enablePlugins(NoPublishPlugin)
.settings(
useCoursier := false, // workaround so we can use an old version in compile
libraryDependencies += {
val oldV = if (tlIsScala3.value) "2.6.1" else "2.0.0"
"org.typelevel" %%% "cats-core" % oldV % Provided

Ok, sorry, and thanks 😁

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to revert to cats.implicits for this one. The point is to make sure we don't break compatibility with old code, so it seems better to write that import the old way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it makes sense, thanks!

satorg
satorg previously approved these changes Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants