scala-hamsters / hamsters

A mini Scala utility library
Apache License 2.0
291 stars 23 forks source link

Macro compilation issues with Scala 2.13 #118

Open loicdescotte opened 5 years ago

loicdescotte commented 5 years ago

See #117

denisftw commented 5 years ago

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?

loicdescotte commented 5 years ago

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

denisftw commented 5 years ago

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.

loicdescotte commented 5 years ago

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 commented 4 years ago

@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

denisftw commented 4 years ago

@loicdescotte Awesome, thanks!