-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support simple higher order pattern splices #7591
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
Support simple higher order pattern splices #7591
Conversation
abafaea
to
3be5d70
Compare
932d63c
to
634e976
Compare
c81f0e1
to
8410346
Compare
8410346
to
b7937b8
Compare
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.
Otherwise, LGTM
import qctx.tasty.{given, _} | ||
val (params, bodyExpr) = paramsAndBody(f) | ||
content(bodyExpr, [t] => (e: Expr[t]) => (v: Expr[T1]) => bodyFn[t](e.unseal, params, List(v.unseal)).seal.asInstanceOf[Expr[t]]) | ||
} |
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.
It's not clear how open/close
is useful. I'd suggest removing them for now.
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 cannot remove it without breaking some tests. I particular those that test the code infrastructure for what @biboudis is working on.
This fixes the quoted pattern matcher runtime to never return open code. * `case '{ val x: Int = 3 ; $body }` will only match if body does not contain a reference to `x`. Same for other kind of definitions in the pattern. * `case '{ val x: Int = 3; ($f: Int => Int)(x) }` will match any body of type `Int` but will wrap it in a lambda that contains `x` as an argument. * Introduce `Expr.open` that takes a expression of a lambda and explicitly opens it temporarily an provides a way to re-close any subexpression of its body (unsafe if not used properly).
b7937b8
to
a5c1ebb
Compare
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.
LGTM
This fixes the quoted pattern matcher runtime to never return open code.
case '{ val x: Int = 3 ; $body }
will only match ifbody
does not contain a reference tox
. Same for other kind of definitions in the pattern.case '{ val x: Int = 3; ($f: Int => Int)(x) }
will match any body of typeInt
but will wrap it in a lambda that containsx
as an argument.Expr.open
that takes a expression of a lambda and explicitly opens it temporarily an provides a way to re-close any subexpression of its body (unsafe if not used properly).