-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add quoted.Exprs and move Value(s) into Expr(s) #8504
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
Conversation
a132c48
to
0dfa827
Compare
As a dual of lifting (`Expr.apply`), unliftings should be placed in the same namespace (`Expr.unapply`). * Move `Values.unapply` to `Exprs.unapply` * Move `Value.unapply` to `Expr.unapply` * Add `Exprs.apply`
0dfa827
to
e023fc7
Compare
@@ -617,7 +617,7 @@ It is possible to deconstruct or extract values out of `Expr` using pattern matc | |||
`scala.quoted` contains objects that can help extracting values from `Expr`. | |||
|
|||
* `scala.quoted.Const`/`scala.quoted.Consts`: matches an expression of a literal value (or list of values) and returns the value (or list of values). | |||
* `scala.quoted.Value`/`scala.quoted.Values`: matches an expression of a value (or list of values) and returns the value (or list of values). | |||
* `scala.quoted.Expr`/`scala.quoted.Exprs`: matches an expression of a value (or list of values) and returns the value (or list of values). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not intuitive --- Expr
and values are very different, conceptually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we say that Expr(x)
takes a value and lifts it into and Expr
, then case Expr(x) =>
takes the value out of the expression. It seems really intuitive but may need to be explained in a better way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe unlift
, to align with Unliftable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we would need to move Expr.apply
to Lift.apply
(or Lifted.apply
). This would break a lot of code.
In a patterns Unlifted
works better, which is a bit too long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will open a PR with the alternative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #8513. It does look semantically clearer. But has migration costs (a deprecation warining).
As a dual of lifting (
Expr.apply
), unliftings should be placed in the same namespace(
Expr.unapply
).Values.unapply
toExprs.unapply
Value.unapply
toExpr.unapply
Exprs.apply