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

Macro Error in FunctionK.lift #3400

Closed
channingwalton opened this issue Apr 24, 2020 · 3 comments · Fixed by #3402
Closed

Macro Error in FunctionK.lift #3400

channingwalton opened this issue Apr 24, 2020 · 3 comments · Fixed by #3402

Comments

@channingwalton
Copy link
Contributor

Hi,
I was wrapping doobie's liftIO in FunctionK:

val lifter: FunctionK[IO, ConnectionIO] = FunctionK.lift(Async[ConnectionIO].liftIO)

and got

Error:(24, 80) Unexpected tree {
  <synthetic> val eta$0$1: cats.effect.Async[doobie.free.connection.ConnectionIO] = cats.effect.Async.apply[doobie.free.connection.ConnectionIO](free.this.connection.AsyncConnectionIO);
  ((ioa: cats.effect.IO[Nothing]) => eta$0$1.liftIO[Nothing](ioa))
} when lifting to FunctionK
  val lifter: FunctionK[IO, ConnectionIO] = FunctionK.lift(Async[ConnectionIO].liftIO)

This fixed it:

val acio = Async[ConnectionIO]
val lifter: FunctionK[IO, ConnectionIO] = FunctionK.lift(acio.liftIO)

@milessabin suggested the macro might have been confused about whether it was supposed to be looking at the Async.apply or the liftIO.

@kailuowang
Copy link
Contributor

There have been some attempts to replace that macro with non macro solutions, but they fell short on being fully backward compatible.
But I think cats remains committed to remove all macro usages in the code base to ease transition to Scala 3.
In short, this issue is probably low priority.

@joroKr21
Copy link
Member

joroKr21 commented Apr 25, 2020

I think it's confused by the eta-expansion.

Which happens to avoid calling Async[ConnectionIO] on every function invocation instead of just once (imagine if Async[ConnectionIO] had side effects).

@channingwalton
Copy link
Contributor Author

Awesome, thank you.

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

Successfully merging a pull request may close this issue.

3 participants