@@ -136,7 +136,7 @@ expressiveness.
136
136
### From ` Expr ` s to Functions and Back
137
137
138
138
It is possible to convert any ` Expr[T => R] ` into ` Expr[T] => Expr[R] ` and back.
139
- These conversions can be written as:
139
+ These conversions can be implemented as follows :
140
140
141
141
``` scala
142
142
def to [T , R ](f : Expr [T ] => Expr [R ])(using QuoteContext ): Expr [T => R ] =
@@ -147,7 +147,7 @@ def from[T, R](f: Expr[T => R])(using QuoteContext): Expr[T] => Expr[R] =
147
147
```
148
148
149
149
Note how the fundamental phase consistency principle works in two
150
- different directions here for ` f ` and ` x ` . The reference to ` f ` is
150
+ different directions here for ` f ` and ` x ` . In the method ` to ` , the reference to ` f ` is
151
151
legal because it is quoted, then spliced, whereas the reference to ` x `
152
152
is legal because it is spliced, then quoted.
153
153
@@ -160,8 +160,8 @@ val f2: Expr[Int] => Expr[String] = from('{ (x: Int) => x.toString }) // (x: Exp
160
160
f2(' {2 }) // '{ ((x: Int) => x.toString)(2) }
161
161
```
162
162
163
- One limitation of ` from ` is that it does not β-reduce as evidenced in the code ` ' { ((x: Int) => x.toString)(2) }` .
164
- In some cases we want to remove the lambda from the code, for this we profide ` Expr.betaReduce ` conversion that turns a tree
163
+ One limitation of ` from ` is that it does not β-reduce when a lambda is called immediately, as evidenced in the code ` { ((x: Int) => x.toString)(2) } ` .
164
+ In some cases we want to remove the lambda from the code, for this we provide the method ` Expr.betaReduce ` that turns a tree
165
165
describing a function into a function mapping trees to trees.
166
166
``` scala
167
167
object Expr {
0 commit comments