Skip to content

Commit fb54ac0

Browse files
committed
Rename FunctionBetaReduction to AsFunction
1 parent e2546fc commit fb54ac0

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

docs/docs/reference/metaprogramming/macros.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,24 +135,24 @@ expressiveness.
135135

136136
### From `Expr`s to Functions and Back
137137

138-
The `Expr` companion object contains an implicit `FunctionBetaReduction` conversion that turns a tree
138+
The `Expr` companion object contains an implicit `AsFunction` conversion that turns a tree
139139
describing a function into a function mapping trees to trees.
140140
```scala
141141
object Expr {
142142
...
143-
implicit class FunctionBetaReduction[...](...) { ... }
143+
implicit class AsFunction[...](...) { ... }
144144
}
145145
```
146146
This decorator gives `Expr` the `apply` operation of an applicative functor, where `Expr`s
147147
over function types can be applied to `Expr` arguments. The definition
148-
of `FunctionBetaReduction(f).apply(x)` is assumed to be functionally the same as
148+
of `AsFunction(f).apply(x)` is assumed to be functionally the same as
149149
`'{($f)($x)}`, however it should optimize this call by returning the
150150
result of beta-reducing `f(x)` if `f` is a known lambda expression.
151151

152-
The `FunctionBetaReduction` decorator distributes applications of `Expr` over function
152+
The `AsFunction` decorator distributes applications of `Expr` over function
153153
arrows:
154154
```scala
155-
FunctionBetaReduction(f).apply: Expr[S => T] => (Expr[S] => Expr[T])
155+
AsFunction(_).apply: Expr[S => T] => (Expr[S] => Expr[T])
156156
```
157157
Its dual, let’s call it `reflect`, can be defined as follows:
158158
```scala

library/src-3.x/scala/quoted/Expr.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ package quoted {
2424
/** Converts a tuple `(T1, ..., Tn)` to `(Expr[T1], ..., Expr[Tn])` */
2525
type TupleOfExpr[Tup <: Tuple] = Tuple.Map[Tup, Expr]
2626

27-
implicit class FunctionBetaReduction[F, Args <: Tuple, R](f: Expr[F]) given (tf: TupledFunction[F, Args => R]) {
27+
implicit class AsFunction[F, Args <: Tuple, R](f: Expr[F]) given (tf: TupledFunction[F, Args => R]) {
2828
/** Beta-reduces the function appication. Generates the an expression only containing the body of the function */
2929
def apply[G] given (tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]]): G =
3030
tg.untupled(args => new FunctionAppliedTo[R](f, args.toArray.map(_.asInstanceOf[Expr[_]])))
3131
}
3232

33-
implicit class ContextualFunctionBetaReduction[F, Args <: Tuple, R](f: Expr[F]) given (tf: TupledFunction[F, given Args => R]) {
33+
implicit class AsContextualFunction[F, Args <: Tuple, R](f: Expr[F]) given (tf: TupledFunction[F, given Args => R]) {
3434
/** Beta-reduces the function appication. Generates the an expression only containing the body of the function */
3535
def apply[G] given (tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]]): G =
3636
tg.untupled(args => new FunctionAppliedTo[R](f, args.toArray.map(_.asInstanceOf[Expr[_]])))

0 commit comments

Comments
 (0)