Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Mar 11, 2020

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

@nicolasstucki nicolasstucki self-assigned this Mar 11, 2020
@nicolasstucki nicolasstucki force-pushed the add-quoted-exprs branch 2 times, most recently from a132c48 to 0dfa827 Compare March 11, 2020 08:36
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`
@nicolasstucki nicolasstucki changed the title Add quoted.Exprs Add quoted.Exprs and move Value(s) into Expr(s) Mar 11, 2020
@nicolasstucki nicolasstucki added this to the 0.23.0-RC1 milestone Mar 11, 2020
@nicolasstucki nicolasstucki marked this pull request as ready for review March 11, 2020 09:16
@@ -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).
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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).

@liufengyun liufengyun deleted the add-quoted-exprs branch March 11, 2020 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants