-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Expr.ofFunction1 #14138
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
Add Expr.ofFunction1 #14138
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,16 @@ object Expr { | |
def unapply[T](x: Expr[T])(using FromExpr[T])(using Quotes): Option[T] = | ||
scala.Predef.summon[FromExpr[T]].unapply(x) | ||
|
||
/** Creates an expression that will construct a function with one parameter | ||
* | ||
* Transforms a sequence of expression | ||
* `a => r` where `a: Expr[A]` and `r: Expr[R]` | ||
* to an expression equivalent to | ||
* `'{ $a => $r }` typed as an `Expr[A => R]` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you're adding a new method to stdlib's API you should mark it as |
||
*/ | ||
def ofFunction1[A, R](f: Expr[A] => Expr[R])(using Type[R], Type[A])(using Quotes): Expr[A => R] = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we add this we should add it for all function arities. It seems that we would need |
||
'{ (a: A) => ${f('a)} } | ||
|
||
/** Creates an expression that will construct a copy of this sequence | ||
* | ||
* Transforms a sequence of expression | ||
|
Uh oh!
There was an error while loading. Please reload this page.