How to support new whitebox macro method in Monocle

Hi. I recently added a new whitebox macro to the Monocle library.

The definition is like this:


object GenIso {
  def fields[S]: Iso[S, _] = macro GenIsoImplW.genIso_fields_impl[S]


And the _ is the type of the case class if it were expressed as a tuple. Examples:

case class C0()
case class C1(int: Int)
case class C2(s: String, i: Int)
case class C3(s: String, x: Int, y: Int)

GenIso.fields[C0] : Iso[C0, Unit]
GenIso.fields[C1] : Iso[C1, Int]
GenIso.fields[C2] : Iso[C2, (String, Int)]
GenIso.fields[C3] : Iso[C3, (String, Int, Int)]


I see that the Scala plugin has MonocleInjector, but that only has injectInner and injectFunctions and I don't understand how I could use either of those two functions to make Intellij understand the correct return type for GenIso.fields. What should we do?

5 comments

We have support for implicit whitebox macros from shapeless. But it's just hardcoded with no API for that. Looks likei it's time to implement API for that too. I'll do that this week.

Best regards,
Alexander Podkhalyuzin.

0

Hi Alexander,

Do you have an idea when the API for whitebox macros will be available?

Thank you

0

I'm planning to do it ASAP (this December). We have everything for that, so task shouldn't be very hard.

Best regards,
Alexadner Podkhalyuzin.

0

Please sign in to leave a comment.