hamsters icon indicating copy to clipboard operation
hamsters copied to clipboard

Macro compilation issues with Scala 2.13

Open loicdescotte opened this issue 7 years ago • 6 comments

See #117

loicdescotte avatar Sep 20 '18 13:09 loicdescotte

Hey @loicdescotte

Do I understand correctly that everything can be compiled with Scala 2.13 except for macro-related things like HList and Show? It seems that Macro Paradise is becoming abandoned, so it's probably better to migrate to something else.

From you comment here I though that Scala 2.13 is supposed to make things easier or I am mistaken?

denisftw avatar Jul 24 '19 05:07 denisftw

Hi @denisftw,

Indeed everything except macros would work with 2.13. The issue is that scala meta macros are not supported anymore so we sould rewrite this macros using scala reflect. It does not only impact Show and HList but mot of our features : https://github.com/scala-hamsters/hamsters/tree/master/metas/shared/src/main/scala/io/github/hamsters

loicdescotte avatar Jul 27 '19 00:07 loicdescotte

Hi @loicdescotte ,

This is indeed more, but it still looks doable (although I have zero experience in writing macros and no authority :)).

If I understand correctly, macro annotations were merged into the Scala compiler (https://github.com/scala/scala/pull/6606) and should be available using a flag. However, I'm not sure it's possible to have this flag and keep old Scala versions supported at the same time. Slinky does it, but the structure looks simpler.

Do you have a branch somewhere that already has desired build.sbt file with satisfactory dependencies and maybe an example of one converted annotation? I guess having something like this would speed things.

denisftw avatar Jul 30 '19 05:07 denisftw

Hi @denisftw, The problem is not with macro paradise but with Scala meta that does not exists for scala 2.13. The solution is to re-write the macros with scala reflect (I think it has been done on Cats for example : https://github.com/typelevel/cats-tagless/issues/6), or to write manually all the methods with different arity (2, 3, 4, ... 22 parameters) . It may be better not to rely on any macro at all since neither scala reflect nor scala meta will be supported in Scala 3.x.

loicdescotte avatar Aug 07 '19 02:08 loicdescotte

@denisftw I've stared to extract modules compatible with Scala 2.13 here : https://github.com/scala-hamsters

for example monad transformers : https://github.com/scala-hamsters/monad-transformers

loicdescotte avatar Feb 27 '20 16:02 loicdescotte

@loicdescotte Awesome, thanks!

denisftw avatar Feb 27 '20 20:02 denisftw