How to generate .tasty files directly?

46 views Asked by At

I know how to inspect a scala 3 .tasty file, as described here 1 2. However, I would like to also go the other way, with the goal of generating one or more scala objects and classes based on an input scala file. The quoted interface (as described here: 3) seems very ergonomic. But it's not clear to me how to accomplish this. There doesn't seem to be a standard interface for constructing .tasty files, let alone through the quoted interface. Can someone point me in the right direction? I feel like possibly I would need to write my code generation as a macro, but then how to call that macro on an AST loaded through the Tasty Inspector interface is uncleart to me.

I know I can also use e.g. ScalaMeta 4 for this. However, I'd prefer to use something that's built into the language. In addition, the quoted code generation facilities are stronger than the string-based code generation from ScalaMeta. Finally, ScalaMeta is usable from Scala 3, but this is not an ordinary dependency and does require some trickery to import, which I'd like to stay away from (admittedly, depending on unstable scala 3 apis is also not great...).

0

There are 0 answers