Skip to content

Commit 6c7ca51

Browse files
Apply suggestions from code review
Co-Authored-By: Fengyun Liu <[email protected]>
1 parent 83b94b1 commit 6c7ca51

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/docs/reference/metaprogramming/macros.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ expressiveness.
136136
### From `Expr`s to Functions and Back
137137

138138
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:
140140

141141
```scala
142142
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] =
147147
```
148148

149149
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
151151
legal because it is quoted, then spliced, whereas the reference to `x`
152152
is legal because it is spliced, then quoted.
153153

@@ -160,8 +160,8 @@ val f2: Expr[Int] => Expr[String] = from('{ (x: Int) => x.toString }) // (x: Exp
160160
f2('{2}) // '{ ((x: Int) => x.toString)(2) }
161161
```
162162

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
165165
describing a function into a function mapping trees to trees.
166166
```scala
167167
object Expr {

0 commit comments

Comments
 (0)