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

Remove macro in FunctionK.lift implementation #2926

Closed
wants to merge 1 commit into from

Conversation

smarter
Copy link
Contributor

@smarter smarter commented Jun 30, 2019

Instead, use the trick proposed by Alex in
#2553 (comment),
this is perhaps not ideal but it seems simpler than maintaining two
separate source files for Scala 2 and Dotty, just for this one function.
Additionally, since Dotty is able to call into non-macro methods in
Scala 2 dependencies, this makes FunctionK.lift usable from
Dotty without cats havin to publish Dotty artifacts.

Co-authored-by: Alexander Konovalov alex.knvl@gmail.com

Instead, use the trick proposed by Alex in
typelevel#2553 (comment),
this is perhaps not ideal but it seems simpler than maintaining two
separate source files for Scala 2 and Dotty, just for this one function.
Additionally, since Dotty is able to call into non-macro methods in
Scala 2 dependencies, this makes FunctionK.lift usable from
Dotty without cats havin to publish Dotty artifacts.

Co-authored-by: Alexander Konovalov <alex.knvl@gmail.com>
@smarter smarter force-pushed the remove-functionk-macro branch from 5c1bd11 to 7902d96 Compare June 30, 2019 16:49
@smarter
Copy link
Contributor Author

smarter commented Jun 30, 2019

Looks like there's no way to avoid at least regressing on type inference with any of the proposed approaches, so I think we'll have to go with split sources.

@smarter smarter closed this Jun 30, 2019
@kailuowang
Copy link
Contributor

Just curious is the type inference regression also happens on 2.13?

@smarter
Copy link
Contributor Author

smarter commented Jul 1, 2019

Yup, same thing:

error] /home/smarter/opt/cats/tests/src/test/scala/cats/tests/FunctionKSuite.scala:88:46: no type parameters for method lift: (f: F[cats.arrow.FunctionK.τ[F,G]] => G[cats.arrow.FunctionK.τ[F,G]])cats.arrow.FunctionK[F,G] exist so that it can be applied to arguments (Option[Nothing] => List[Nothing])
[error]  --- because ---
[error] argument expression's type is not compatible with formal parameter type;
[error]  found   : Option[Nothing] => List[Nothing]
[error]  required: ?F[cats.arrow.FunctionK.τ[?F,?G]] => ?G[cats.arrow.FunctionK.τ[?F,?G]]
[error]     val fOptionToList = cats.arrow.FunctionK.lift(optionToList _)
[error]                                              ^

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 this pull request may close these issues.

2 participants