TermModule

scala.quoted.Quotes.reflectModule.TermModule
trait TermModule

Methods of the module object val Term

Attributes

Source
Quotes.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Term.type

Members list

Value members

Abstract methods

def betaReduce(term: Term): Option[Term]

Returns a term that is functionally equivalent to t, however if t is of the form ((y1, ..., yn) => e2)(e1, ..., en) then it optimizes the top most call by returning Some with the result of beta-reducing the function application. Similarly, all outermost curried function applications will be beta-reduced, if possible. Otherwise returns None.

Returns a term that is functionally equivalent to t, however if t is of the form ((y1, ..., yn) => e2)(e1, ..., en) then it optimizes the top most call by returning Some with the result of beta-reducing the function application. Similarly, all outermost curried function applications will be beta-reduced, if possible. Otherwise returns None.

To retain semantics the argument ei is bound as val yi = ei and by-name arguments to def yi = ei. Some bindings may be elided as an early optimization.

Example:

((a: Int, b: Int) => a + b).apply(x, y)

will be reduced to

val a = x
val b = y
a + b

Generally:

([X1, Y1, ...] => (x1, y1, ...) => ... => [Xn, Yn, ...] => (xn, yn, ...) => f[X1, Y1, ..., Xn, Yn, ...](x1, y1, ..., xn, yn, ...))).apply[Tx1, Ty1, ...](myX1, myY1, ...)....apply[Txn, Tyn, ...](myXn, myYn, ...)

will be reduced to

type X1 = Tx1
type Y1 = Ty1
...
val x1 = myX1
val y1 = myY1
...
type Xn = Txn
type Yn = Tyn
...
val xn = myXn
val yn = myYn
...
f[X1, Y1, ..., Xn, Yn, ...](x1, y1, ..., xn, yn, ...)

Attributes

Source
Quotes.scala