Movatterモバイル変換


[0]ホーム

URL:


Scala 3
3.7.4
LearnInstallPlaygroundFind A LibraryCommunityBlog
Scala 3
LearnInstallPlaygroundFind A LibraryCommunityBlog
DocsAPI
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL
Scala 3/scala/scala.quoted/Expr

Expr

scala.quoted.Expr
See theExpr companion class
objectExpr

Constructors for expressions

Attributes

Companion
class
Source
Expr.scala
Graph
Supertypes
classObject
traitMatchable
classAny
Self type
Expr.type

Members list

Value members

Concrete methods

defapply[T](x:T)(usingToExpr[T])(usingQuotes):Expr[T]

Creates an expression that will construct the valuex

Creates an expression that will construct the valuex

Attributes

Source
Expr.scala
defbetaReduce[T](expr:Expr[T])(usingQuotes):Expr[T]

e.betaReduce returns an expression that is functionally equivalent toe, however ife is of the form((y1, ..., yn) => e2)(e1, ..., en) then it optimizes the top most call by returning the result of beta-reducing the application. Similarly, all outermost curried function applications will be beta-reduced, if possible. Otherwise returnsexpr.

e.betaReduce returns an expression that is functionally equivalent toe, however ife is of the form((y1, ..., yn) => e2)(e1, ..., en) then it optimizes the top most call by returning the result of beta-reducing the application. Similarly, all outermost curried function applications will be beta-reduced, if possible. Otherwise returnsexpr.

To retain semantics the argumentei is bound asval yi = ei and by-name arguments todef 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 = xval b = ya + 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 = Tx1type Y1 = Ty1...val x1 = myX1val y1 = myY1...type Xn = Txntype Yn = Tyn...val xn = myXnval yn = myYn...f[X1, Y1, ..., Xn, Yn, ...](x1, y1, ..., xn, yn, ...)

Attributes

Source
Expr.scala
defblock[T](statements:List[Expr[Any]],expr:Expr[T])(usingQuotes):Expr[T]

Returns an expression containing a block with the given statements and ending with the expression Given list of statementss1 :: s2 :: ... :: Nil and an expressione the resulting expression will be equivalent to'{ $s1; $s2; ...; $e }.

Returns an expression containing a block with the given statements and ending with the expression Given list of statementss1 :: s2 :: ... :: Nil and an expressione the resulting expression will be equivalent to'{ $s1; $s2; ...; $e }.

Attributes

Source
Expr.scala
defofList[T](xs:Seq[Expr[T]])(usingType[T])(usingQuotes):Expr[List[T]]

Creates an expression that will construct a copy of this list

Creates an expression that will construct a copy of this list

Transforms a list of expressionList(e1, e2, ...) whereei: Expr[T] to an expression equivalent to'{ List($e1, $e2, ...) } typed as anExpr[List[T]]

Attributes

Source
Expr.scala
defofSeq[T](xs:Seq[Expr[T]])(usingType[T])(usingQuotes):Expr[Seq[T]]

Creates an expression that will construct a copy of this sequence

Creates an expression that will construct a copy of this sequence

Transforms a sequence of expressionSeq(e1, e2, ...) whereei: Expr[T] to an expression equivalent to'{ Seq($e1, $e2, ...) } typed as anExpr[Seq[T]]

Attributes

Source
Expr.scala
defofTuple[T <:Tuple](tup:T)(usingevidence$1:IsMappedBy[Expr][T],evidence$2:Type[T],Quotes):Expr[InverseMap[T,Expr]]

Given a tuple of the form(Expr[A1], ..., Expr[An]), outputs a tupleExpr[(A1, ..., An)].

Given a tuple of the form(Expr[A1], ..., Expr[An]), outputs a tupleExpr[(A1, ..., An)].

Attributes

Source
Expr.scala

Creates an expression that will construct a copy of this tuple

Creates an expression that will construct a copy of this tuple

Transforms a sequence of expressionSeq(e1, e2, ...) whereei: Expr[Any] to an expression equivalent to'{ ($e1, $e2, ...) } typed as anExpr[Tuple]

Attributes

Source
Expr.scala
defsummon[T](usingType[T])(usingQuotes):Option[Expr[T]]

Find a given instance of typeT in the current scope. ReturnSome containing the expression of the implicit orNone if implicit resolution failed.

Find a given instance of typeT in the current scope. ReturnSome containing the expression of the implicit orNone if implicit resolution failed.

Type parameters

T

type of the implicit parameter

Attributes

Source
Expr.scala
defsummonIgnoring[T](usingType[T])(usingquotes:Quotes)(ignored: quotes.reflect.Symbol*):Option[Expr[T]]

Find a given instance of typeT in the current scope, while excluding certain symbols from the initial implicit search. ReturnSome containing the expression of the implicit orNone if implicit resolution failed.

Find a given instance of typeT in the current scope, while excluding certain symbols from the initial implicit search. ReturnSome containing the expression of the implicit orNone if implicit resolution failed.

Type parameters

T

type of the implicit parameter

Value parameters

ignored

Symbols ignored during the initial implicit search

Attributes

Note

if the found given requires additional search for other given instances, this additional search will NOT exclude the symbols from theignored list.

Source
Expr.scala
defunapply[T](x:Expr[T])(usingFromExpr[T])(usingQuotes):Option[T]

GetSome of a copy of the value if the expression contains a literal constant or constructor ofT. Otherwise returnsNone.

GetSome of a copy of the value if the expression contains a literal constant or constructor ofT. Otherwise returnsNone.

Usage:

case '{ ... ${expr @ Expr(value)}: T ...} =>  // expr: Expr[T]  // value: T

To directly get the value of an expressionexpr: Expr[T] consider usingexpr.value/expr.valueOrError instead.

Attributes

Source
Expr.scala
In this article
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL

[8]ページ先頭

©2009-2025 Movatter.jp