-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
Mononcle doesn't support @Lenses
in Scala3.
#1337
Comments
Scala 3 doesn't support (yet) macro annotations such as |
I am no expert, but following these PR's I'm under the impression this is still impossible under Scala3 post-typer Macro Annotations. I'm sure there will be other similar opportunities under the new Scala3 metaprogramming facilities, but in any case, Macro Annotations have been merged since |
@nkgm correct. I think a more fruitful approach would actually be to lobby for inclusion in Scala proper. It doesn't mean including an optics library, just the following: A. A case class or something basically of the form A macro that generates a single one would be very easy to write, so there's no need for them to special-case that. Meanwhile, the recommended migration path is to use the focus macros instead. Although, I wonder if there's a performance effect, since lenses as fields would reuse the same instance. |
I think it's been enough time that we need to start looking into alternatives for folks to migrate. Off the top of my head I know that simulacrum looked into using scalafix rules to do this. |
Maybe some way with named tuples? Or like I said before, just start a pre-SIP. Code gen seems dubious since it belongs in a companion. Unless I make the companions extend a trait that is generated. The quick fix approach that was discussed on the forums might be interesting though. |
I was hoping to do the rewrite pre-compliation so it wouldn't be in your source tree; for all intents and purposes it would just allow the same source to be used for Scala 2/3. What quick fix approach were you referencing? |
The idea discussed here: https://contributors.scala-lang.org/t/scala-3-macro-annotations-and-code-generation/6035 |
How can code not in the source tree be part of the companion object of code that is |
Some build tools ( In this build model, it's quite trivial to rewrite the sources before the compile step - I'm not entirely sure whether The idea would be to look for the |
I made a source generator at work for our case, it doesn't handle all possible cases (e.g. nested classes, imports) but sharing it in case it is helpful for others or if someone want to make it better and more reusable. https://gist.github.com/ghostdogpr/3b5bd33dd3356e16434db42595924bf4 |
I used
@Lenses
macro annotation in Scala2, but I can't find@Lenses
in Monocle 3.1.0 with Scala3.Does anyone know anything about this issue?
Does Monocle have any plan to support
@Lenses
in Scala3?The text was updated successfully, but these errors were encountered: