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

tailRec instances aren't visible by default #4652

Closed
kubukoz opened this issue Sep 12, 2024 · 5 comments
Closed

tailRec instances aren't visible by default #4652

kubukoz opened this issue Sep 12, 2024 · 5 comments

Comments

@kubukoz
Copy link
Member

kubukoz commented Sep 12, 2024

As far as I know, import cats.syntax.all.* is now the recommended mega-import. However, it doesn't bring the instances for scala.util.control.TailCalls.TailRec - those still require import cats.instances.tailRec.*.

These instances should probably be included in the companion objects of the typeclasses themselves so that they're auto-discoverable like most other instances.

@aluscent
Copy link
Contributor

aluscent commented Dec 8, 2024

@kubukoz I'm interested in helping on this issue.
As I assumed from your explanation, we need to add implicit instances of the TailRecInstances into Defer and StackSafeMonad, right? Please give me more details and help me understand the problem.

@kubukoz
Copy link
Member Author

kubukoz commented Dec 18, 2024

I just checked and Defer[TailRec] already is in the companion of Defer: implicit def catsDeferForTailRec: Defer[TailRec].

StackSafeMonad isn't a typeclass per se, I'm actually not sure why it appears in the type annotation (should be just Monad IMO)...

but there's a Monad[TailRec] in the companion object of Invariant too: implicit def catsMonadForTailRec: Monad[TailRec] - so I don't see why I opened this issue in the first place...

This works fine on 2.12, 2.13 and 3.x:

//> using dep org.typelevel::cats-core:2.12.0
import scala.util.control.TailCalls.TailRec
import cats.Monad
import cats.Defer

object Demo extends App {

  println(Monad[TailRec])
  println(Defer[TailRec])

}

@kubukoz
Copy link
Member Author

kubukoz commented Dec 18, 2024

Maybe there's a combination of compiler flags that causes the instances not to be picked up, but so far this seems like a non-issue.

@aluscent
Copy link
Contributor

@kubukoz Thank you for checking!
As you discussed this is not an issue anymore. Do you think this thread should be closed?

@kubukoz
Copy link
Member Author

kubukoz commented Dec 20, 2024

yeah, I don't think I can reproduce it now.

@kubukoz kubukoz closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2024
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

2 participants