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

Scala 3: No given instance of type cats.Applicative[[_] =>> Any] was found for parameter F of method apply in class PurePartiallyApplied #4499

Open
froth opened this issue Aug 24, 2023 · 0 comments

Comments

@froth
Copy link

froth commented Aug 24, 2023

I am currently migrating code from scala 2.13 to Scala 3 and found a weird issue. I am not sure whether this is a bug or not. And also sure whether it should be reported here or on http4s. Opening to be sure:

The following code compiles under scala 2.13:

import org.http4s.server.AuthMiddleware
import cats.data.Kleisli
import cats.data.OptionT
val middleware = AuthMiddleware(Kleisli { _ => OptionT.pure { "foo" } })

But reports compile errors under scala3:

[error] -- [E172] Type Error: /tmp/quickstart/src/main/scala/com/example/quickstart/Main.scala:12:71 
[error] 12 |  val middleware = AuthMiddleware(Kleisli { _ => OptionT.pure { "foo" } })
[error]    |                                                                       ^
[error]    |No given instance of type cats.Applicative[[_] =>> Any] was found for parameter F of method apply in class PurePartiallyApplied
[error]    |
[error]    |One of the following imports might make progress towards fixing the problem:
[error]    |
[error]    |  import fs2.Compiler.Target.forConcurrent
[error]    |  import fs2.Compiler.Target.forSync
[error]    |
[error] -- [E172] Type Error: /tmp/quickstart/src/main/scala/com/example/quickstart/Main.scala:12:74 
[error] 12 |  val middleware = AuthMiddleware(Kleisli { _ => OptionT.pure { "foo" } })
[error]    |                                                                          ^
[error]    |No given instance of type cats.Monad[[_] =>> Any] was found for an implicit parameter of method apply in object AuthMiddleware
[error]    |
[error]    |One of the following imports might make progress towards fixing the problem:
[error]    |
[error]    |  import fs2.Compiler.Target.forConcurrent
[error]    |  import fs2.Compiler.Target.forSync
[error]    |

The following variant compiles under scala 3:

val response: Kleisli[OptionT[IO, *], Request[IO], String] = Kleisli { _ => OptionT.pure { "foo" } }
val middleware = AuthMiddleware(response)
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

1 participant