From 57b59b317061ab20a8335cf7e6444ea1753b26e6 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 23 Sep 2019 21:06:05 +0200 Subject: [PATCH 1/4] Replace AsFunction implicit class with Expr.reduce --- .../community-projects/xml-interpolator | 2 +- docs/docs/reference/metaprogramming/macros.md | 14 +-- library/src/scala/quoted/Expr.scala | 20 ++-- tests/pos/i6783.scala | 2 +- .../gestalt-optional-staging/Macro_1.scala | 2 +- tests/run-macros/i4734/Macro_1.scala | 4 +- tests/run-macros/i4735/Macro_1.scala | 2 +- tests/run-macros/i7008/macro_1.scala | 2 +- .../quote-inline-function/quoted_1.scala | 4 +- .../quote-matcher-symantics-2/quoted_1.scala | 2 +- .../quote-matching-optimize-1/Macro_1.scala | 6 +- .../quote-matching-optimize-2/Macro_1.scala | 6 +- .../quote-unrolled-foreach/quoted_1.scala | 2 +- .../tasty-seal-method/quoted_1.scala | 16 ++-- .../tasty-unsafe-let/quoted_1.scala | 2 +- tests/run-staging/i3876-b.scala | 4 +- tests/run-staging/i3876-c.scala | 4 +- tests/run-staging/i3876-d.scala | 4 +- tests/run-staging/i3876-e.scala | 4 +- tests/run-staging/i3876.scala | 4 +- tests/run-staging/i5144b.scala | 2 +- tests/run-staging/i6281.scala | 6 +- tests/run-staging/quote-ackermann-1.scala | 2 +- tests/run-staging/quote-fun-app-1.scala | 6 +- .../quote-function-applied-to.scala | 91 ++++++++++--------- .../run-staging/quote-unrolled-foreach.scala | 2 +- 26 files changed, 104 insertions(+), 111 deletions(-) diff --git a/community-build/community-projects/xml-interpolator b/community-build/community-projects/xml-interpolator index ddbda123addf..0bc5a4fd140b 160000 --- a/community-build/community-projects/xml-interpolator +++ b/community-build/community-projects/xml-interpolator @@ -1 +1 @@ -Subproject commit ddbda123addfcb255edab25e24fec51f16671fa9 +Subproject commit 0bc5a4fd140b2af1e6e412e7ef09ce0bcfb2596f diff --git a/docs/docs/reference/metaprogramming/macros.md b/docs/docs/reference/metaprogramming/macros.md index 0b97aa385acf..01fcb4113f2e 100644 --- a/docs/docs/reference/metaprogramming/macros.md +++ b/docs/docs/reference/metaprogramming/macros.md @@ -135,24 +135,20 @@ expressiveness. ### From `Expr`s to Functions and Back -The `Expr` companion object contains an implicit `AsFunction` conversion that turns a tree +The `Expr` companion object contains a `reduce` conversion that turns a tree describing a function into a function mapping trees to trees. ```scala object Expr { ... - implicit class AsFunction[...](...) { ... } + def reduce[...](...)(...): ... = } ``` -This decorator gives `Expr` the `apply` operation of an applicative functor, where `Expr`s -over function types can be applied to `Expr` arguments. The definition -of `AsFunction(f).apply(x)` is assumed to be functionally the same as +The definition of `Expr.reduce(f)(x)` is assumed to be functionally the same as `'{($f)($x)}`, however it should optimize this call by returning the result of beta-reducing `f(x)` if `f` is a known lambda expression. - -The `AsFunction` decorator distributes applications of `Expr` over function -arrows: +`Expr.reduce` distributes applications of `Expr` over function arrows: ```scala -AsFunction(_).apply: Expr[S => T] => (Expr[S] => Expr[T]) +Expr.reduce(_).apply: Expr[(T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) ``` Its dual, let’s call it `reflect`, can be defined as follows: ```scala diff --git a/library/src/scala/quoted/Expr.scala b/library/src/scala/quoted/Expr.scala index 0d9c5da19321..711813587c18 100644 --- a/library/src/scala/quoted/Expr.scala +++ b/library/src/scala/quoted/Expr.scala @@ -28,20 +28,16 @@ package quoted { /** Converts a tuple `(T1, ..., Tn)` to `(Expr[T1], ..., Expr[Tn])` */ type TupleOfExpr[Tup <: Tuple] = Tuple.Map[Tup, [X] =>> (given QuoteContext) => Expr[X]] - implicit class AsFunction[F, Args <: Tuple, R](f: Expr[F])(given tf: TupledFunction[F, Args => R], qctx: QuoteContext) { - /** Beta-reduces the function appication. Generates the an expression only containing the body of the function */ - def apply[G](given tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]]): G = { - import qctx.tasty._ - tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) - } + /** Beta-reduces the function appication. Generates the an expression only containing the body of the function */ + def reduce[F, Args <: Tuple, R, G](f: Expr[F])(given tf: TupledFunction[F, Args => R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G = { + import qctx.tasty._ + tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) } - implicit class AsContextualFunction[F, Args <: Tuple, R](f: Expr[F])(given tf: TupledFunction[F, (given Args) => R], qctx: QuoteContext) { - /** Beta-reduces the function appication. Generates the an expression only containing the body of the function */ - def apply[G](given tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]]): G = { - import qctx.tasty._ - tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) - } + /** Beta-reduces the function appication. Generates the an expression only containing the body of the function */ + def reduceGiven[F, Args <: Tuple, R, G](f: Expr[F])(given tf: TupledFunction[F, (given Args) => R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G = { + import qctx.tasty._ + tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) } /** Returns a null expresssion equivalent to `'{null}` */ diff --git a/tests/pos/i6783.scala b/tests/pos/i6783.scala index 462edf1f3f36..dc0118fd8d7a 100644 --- a/tests/pos/i6783.scala +++ b/tests/pos/i6783.scala @@ -1,6 +1,6 @@ import scala.quoted._ -def testImpl(f: Expr[(Int, Int) => Int])(given QuoteContext): Expr[Int] = f('{1}, '{2}) +def testImpl(f: Expr[(Int, Int) => Int])(given QuoteContext): Expr[Int] = Expr.reduce(f)('{1}, '{2}) inline def test(f: (Int, Int) => Int) = ${ testImpl('f) diff --git a/tests/run-macros/gestalt-optional-staging/Macro_1.scala b/tests/run-macros/gestalt-optional-staging/Macro_1.scala index 81ec2d8e70d1..1d55cb17087d 100644 --- a/tests/run-macros/gestalt-optional-staging/Macro_1.scala +++ b/tests/run-macros/gestalt-optional-staging/Macro_1.scala @@ -24,7 +24,7 @@ object Optional { // FIXME fix issue #5097 and enable private /*private*/ def mapImpl[A >: Null : Type, B >: Null : Type](opt: Expr[Optional[A]], f: Expr[A => B])(given QuoteContext): Expr[Optional[B]] = '{ if ($opt.isEmpty) new Optional(null) - else new Optional(${f('{$opt.value})}) + else new Optional(${Expr.reduce(f)('{$opt.value})}) } } diff --git a/tests/run-macros/i4734/Macro_1.scala b/tests/run-macros/i4734/Macro_1.scala index 9d4b0ed8b218..dbc9da9d0bb4 100644 --- a/tests/run-macros/i4734/Macro_1.scala +++ b/tests/run-macros/i4734/Macro_1.scala @@ -13,9 +13,9 @@ object Macros { while (i < size) { ${ for (j <- new UnrolledRange(0, unrollSize)) '{ - val index = i + ${j} + val index = i + $j val element = ($seq)(index) - ${ f('element) } // or `($f)(element)` if `f` should not be inlined + ${ Expr.reduce(f)('element) } // or `($f)(element)` if `f` should not be inlined } } i += ${unrollSize} diff --git a/tests/run-macros/i4735/Macro_1.scala b/tests/run-macros/i4735/Macro_1.scala index 8154b87e1191..6351204a332c 100644 --- a/tests/run-macros/i4735/Macro_1.scala +++ b/tests/run-macros/i4735/Macro_1.scala @@ -17,7 +17,7 @@ object Macro { ${ for (j <- new UnrolledRange(0, unrollSize)) '{ val element = ($seq)(i + ${j}) - ${f('element)} // or `($f)(element)` if `f` should not be inlined + ${Expr.reduce(f)('element)} // or `($f)(element)` if `f` should not be inlined } } i += ${unrollSize} diff --git a/tests/run-macros/i7008/macro_1.scala b/tests/run-macros/i7008/macro_1.scala index 4a83e57fc175..81ddaa51ece1 100644 --- a/tests/run-macros/i7008/macro_1.scala +++ b/tests/run-macros/i7008/macro_1.scala @@ -15,5 +15,5 @@ def mcrProxy(expr: Expr[Boolean])(given QuoteContext): Expr[Unit] = { def mcrImpl[T](func: Expr[Seq[Box[T]] => Unit], expr: Expr[T])(given ctx: QuoteContext, tt: Type[T]): Expr[Unit] = { import ctx.tasty._ val arg = Expr.ofSeq(Seq('{(Box($expr))})) - func(arg) + Expr.reduce(func)(arg) } \ No newline at end of file diff --git a/tests/run-macros/quote-inline-function/quoted_1.scala b/tests/run-macros/quote-inline-function/quoted_1.scala index 463a20b0e6ff..2ad4a5e216eb 100644 --- a/tests/run-macros/quote-inline-function/quoted_1.scala +++ b/tests/run-macros/quote-inline-function/quoted_1.scala @@ -12,11 +12,11 @@ object Macros { var i = $start val j = $end while (i < j) { - ${f.apply('i)} + ${Expr.reduce(f)('i)} i += 1 } while { - ${f.apply('i)} + ${Expr.reduce(f)('i)} i += 1 i < j } do () diff --git a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala index e654da688779..be6d0537b4f7 100644 --- a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala @@ -72,7 +72,7 @@ object StringNum extends Symantics[String] { def value(x: Int)(given QuoteContext): Expr[String] = Expr(x.toString) def plus(x: Expr[String], y: Expr[String])(given QuoteContext): Expr[String] = '{ s"${$x} + ${$y}" } // '{ x + " + " + y } def times(x: Expr[String], y: Expr[String])(given QuoteContext): Expr[String] = '{ s"${$x} * ${$y}" } - def app(f: Expr[String => String], x: Expr[String])(given QuoteContext): Expr[String] = f(x) // functions are beta reduced + def app(f: Expr[String => String], x: Expr[String])(given QuoteContext): Expr[String] = Expr.reduce(f)(x) def lam(body: Expr[String] => Expr[String])(given QuoteContext): Expr[String => String] = '{ (x: String) => ${body('x)} } } diff --git a/tests/run-macros/quote-matching-optimize-1/Macro_1.scala b/tests/run-macros/quote-matching-optimize-1/Macro_1.scala index d0f6d4743cef..872609abd2fb 100644 --- a/tests/run-macros/quote-matching-optimize-1/Macro_1.scala +++ b/tests/run-macros/quote-matching-optimize-1/Macro_1.scala @@ -9,13 +9,13 @@ object Macro { def optimize(x: Expr[Any]): Expr[Any] = x match { case '{ type $t; ($ls: List[`$t`]).filter($f).filter($g) } => - optimize('{ $ls.filter(x => ${f('x)} && ${g('x)}) }) + optimize('{ $ls.filter(x => ${Expr.reduce(f)('x)} && ${Expr.reduce(g)('x)}) }) case '{ type $t; type $u; type $v; ($ls: List[`$t`]).map[`$u`]($f).map[`$v`]($g) } => - optimize('{ $ls.map(x => ${g(f('x))}) }) + optimize('{ $ls.map(x => ${Expr.reduce(g)(Expr.reduce(f)('x))}) }) case '{ type $t; ($ls: List[`$t`]).filter($f).foreach[Unit]($g) } => - optimize('{ $ls.foreach(x => if (${f('x)}) ${g('x)} else ()) }) + optimize('{ $ls.foreach(x => if (${Expr.reduce(f)('x)}) ${Expr.reduce(g)('x)} else ()) }) case _ => x } diff --git a/tests/run-macros/quote-matching-optimize-2/Macro_1.scala b/tests/run-macros/quote-matching-optimize-2/Macro_1.scala index 9729303d19a7..44895ecf5e4b 100644 --- a/tests/run-macros/quote-matching-optimize-2/Macro_1.scala +++ b/tests/run-macros/quote-matching-optimize-2/Macro_1.scala @@ -11,13 +11,13 @@ object Macro { def optimize(x: Expr[Any]): Expr[Any] = x match { case '{ ($ls: List[$t]).filter($f).filter($g) } => - optimize('{ $ls.filter(x => ${f('x)} && ${g('x)}) }) + optimize('{ $ls.filter(x => ${Expr.reduce(f)('x)} && ${Expr.reduce(g)('x)}) }) case '{ type $u; type $v; ($ls: List[$t]).map[`$u`]($f).map[`$v`]($g) } => - optimize('{ $ls.map(x => ${g(f('x))}) }) + optimize('{ $ls.map(x => ${Expr.reduce(g)(Expr.reduce(f)('x))}) }) case '{ ($ls: List[$t]).filter($f).foreach[$u]($g) } => - optimize('{ $ls.foreach[Any](x => if (${f('x)}) ${g('x)} else ()) }) + optimize('{ $ls.foreach[Any](x => if (${Expr.reduce(f)('x)}) ${Expr.reduce(g)('x)} else ()) }) case _ => x } diff --git a/tests/run-macros/quote-unrolled-foreach/quoted_1.scala b/tests/run-macros/quote-unrolled-foreach/quoted_1.scala index 761a297f5e01..dcd48c4123cf 100644 --- a/tests/run-macros/quote-unrolled-foreach/quoted_1.scala +++ b/tests/run-macros/quote-unrolled-foreach/quoted_1.scala @@ -15,7 +15,7 @@ object Macro { println(" start loop") ${ @tailrec def loop(j: Int, acc: Expr[Unit]): Expr[Unit] = - if (j >= 0) loop(j - 1, '{ ${f('{$seq(i + ${j})})}; $acc }) + if (j >= 0) loop(j - 1, '{ ${Expr.reduce(f)('{$seq(i + ${j})})}; $acc }) else acc loop(unrollSize - 1, '{}) } diff --git a/tests/run-macros/tasty-seal-method/quoted_1.scala b/tests/run-macros/tasty-seal-method/quoted_1.scala index e3ac0d8c73e2..97bf8b000a0e 100644 --- a/tests/run-macros/tasty-seal-method/quoted_1.scala +++ b/tests/run-macros/tasty-seal-method/quoted_1.scala @@ -14,10 +14,10 @@ object Asserts { fn.tpe.widen match { case Type.IsMethodType(_) => args.size match { - case 0 => fn.seal.cast[() => Int].apply() - case 1 => fn.seal.cast[Int => Int].apply('{0}) - case 2 => fn.seal.cast[(Int, Int) => Int].apply('{0}, '{0}) - case 3 => fn.seal.cast[(Int, Int, Int) => Int].apply('{0}, '{0}, '{0}) + case 0 => Expr.reduce(fn.seal.cast[() => Int])() + case 1 => Expr.reduce(fn.seal.cast[Int => Int])('{0}) + case 2 => Expr.reduce(fn.seal.cast[(Int, Int) => Int])('{0}, '{0}) + case 3 => Expr.reduce(fn.seal.cast[(Int, Int, Int) => Int])('{0}, '{0}, '{0}) } } case _ => x @@ -35,10 +35,10 @@ object Asserts { case Apply(fn, args) => val pre = rec(fn) args.size match { - case 0 => pre.seal.cast[() => Any].apply().unseal - case 1 => pre.seal.cast[Int => Any].apply('{0}).unseal - case 2 => pre.seal.cast[(Int, Int) => Any].apply('{0}, '{0}).unseal - case 3 => pre.seal.cast[(Int, Int, Int) => Any].apply('{0}, '{0}, '{0}).unseal + case 0 => Expr.reduce(pre.seal.cast[() => Any])().unseal + case 1 => Expr.reduce(pre.seal.cast[Int => Any])('{0}).unseal + case 2 => Expr.reduce(pre.seal.cast[(Int, Int) => Any])('{0}, '{0}).unseal + case 3 => Expr.reduce(pre.seal.cast[(Int, Int, Int) => Any])('{0}, '{0}, '{0}).unseal } case _ => term } diff --git a/tests/run-macros/tasty-unsafe-let/quoted_1.scala b/tests/run-macros/tasty-unsafe-let/quoted_1.scala index e66397563674..7fc9bc123a4d 100644 --- a/tests/run-macros/tasty-unsafe-let/quoted_1.scala +++ b/tests/run-macros/tasty-unsafe-let/quoted_1.scala @@ -12,7 +12,7 @@ object Macros { import qctx.tasty.{let => letTerm} letTerm(rhsTerm) { rhsId => - body(rhsId.seal.asInstanceOf[Expr[T]]).unseal // Dangerous uncheked cast! + Expr.reduce(body)(rhsId.seal.asInstanceOf[Expr[T]]).unseal // Dangerous uncheked cast! }.seal.cast[Unit] } diff --git a/tests/run-staging/i3876-b.scala b/tests/run-staging/i3876-b.scala index 8af67c260c76..205a44c50e7a 100644 --- a/tests/run-staging/i3876-b.scala +++ b/tests/run-staging/i3876-b.scala @@ -11,7 +11,7 @@ object Test { f } - println(run(f2(x))) - println(withQuoteContext(f2(x).show)) + println(run(Expr.reduce(f2)(x))) + println(withQuoteContext(Expr.reduce(f2)(x).show)) } } diff --git a/tests/run-staging/i3876-c.scala b/tests/run-staging/i3876-c.scala index 45c80251a14b..fde986399147 100644 --- a/tests/run-staging/i3876-c.scala +++ b/tests/run-staging/i3876-c.scala @@ -11,7 +11,7 @@ object Test { f } - println(run(f3(x))) - println(withQuoteContext(f3(x).show)) // TODO improve printer + println(run(Expr.reduce(f3)(x))) + println(withQuoteContext(Expr.reduce(f3)(x).show)) // TODO improve printer } } diff --git a/tests/run-staging/i3876-d.scala b/tests/run-staging/i3876-d.scala index f75c85dd49b4..c1a4020e9652 100644 --- a/tests/run-staging/i3876-d.scala +++ b/tests/run-staging/i3876-d.scala @@ -9,8 +9,8 @@ object Test { def f4(given QuoteContext): Expr[Int => Int] = '{ inlineLambda } - println(run(f4(x))) - println(withQuoteContext(f4(x).show)) + println(run(Expr.reduce(f4)(x))) + println(withQuoteContext(Expr.reduce(f4)(x).show)) } inline def inlineLambda <: Int => Int = x => x + x diff --git a/tests/run-staging/i3876-e.scala b/tests/run-staging/i3876-e.scala index 1abfd765244b..84f63986b829 100644 --- a/tests/run-staging/i3876-e.scala +++ b/tests/run-staging/i3876-e.scala @@ -9,8 +9,8 @@ object Test { def f4(given QuoteContext): Expr[Int => Int] = '{ inlineLambda } - println(run(f4(x))) - println(withQuoteContext(f4(x).show)) + println(run(Expr.reduce(f4)(x))) + println(withQuoteContext(Expr.reduce(f4)(x).show)) } inline def inlineLambda <: Int => Int = x => x + x diff --git a/tests/run-staging/i3876.scala b/tests/run-staging/i3876.scala index adae2d9e01ab..a32b1c83fc4f 100644 --- a/tests/run-staging/i3876.scala +++ b/tests/run-staging/i3876.scala @@ -8,7 +8,7 @@ object Test { def f(given QuoteContext): Expr[Int => Int] = '{ (x: Int) => x + x } - println(run(f(x))) - println(withQuoteContext(f(x).show)) + println(run(Expr.reduce(f)(x))) + println(withQuoteContext(Expr.reduce(f)(x).show)) } } diff --git a/tests/run-staging/i5144b.scala b/tests/run-staging/i5144b.scala index b805c486c0c4..1bc59331eb43 100644 --- a/tests/run-staging/i5144b.scala +++ b/tests/run-staging/i5144b.scala @@ -3,7 +3,7 @@ import scala.quoted.staging._ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) - def eval1(ff: Expr[Int => Int])(given QuoteContext): Expr[Int] = ff('{42}) + def eval1(ff: Expr[Int => Int])(given QuoteContext): Expr[Int] = Expr.reduce(ff)('{42}) def peval1()(given QuoteContext): Expr[Unit] = '{ def f(x: Int): Int = ${eval1('f)} diff --git a/tests/run-staging/i6281.scala b/tests/run-staging/i6281.scala index 801644ca98da..2524d82de983 100644 --- a/tests/run-staging/i6281.scala +++ b/tests/run-staging/i6281.scala @@ -27,8 +27,8 @@ object Test extends App { } // for reify, we need type tags for E and also strangely for L. implicit def cons [E, L <: HList](given Effects[L])(given Type[E])(given Type[L])(given QuoteContext): Effects[E :: L] = new Effects[E :: L] { - def reify[A](given Type[A]) = m => '{ k => ${ Effects[L].reify[E] { m( a => Effects[L].reflect[E]('k(a))) } }} - def reflect[A](given Type[A]) = m => k => Effects[L].reflect[E] { m('{ a => ${ Effects[L].reify[E]( k('a)) } })} + def reify[A](given Type[A]) = m => '{ k => ${ Effects[L].reify[E] { m( a => Effects[L].reflect[E](Expr.reduce('k)(a))) } }} + def reflect[A](given Type[A]) = m => k => Effects[L].reflect[E] { Expr.reduce(m)('{ a => ${ Effects[L].reify[E]( k('a)) } })} } def Effects[L <: HList](given Effects[L]): Effects[L] = summon[Effects[L]] @@ -45,7 +45,7 @@ object Test extends App { val effects = cons[Boolean, RS2](given cons[Int, String :: HNil](given cons[String, HNil](given empty))) println(effects.reify[Int] { m }.show) - val res : Expr[Stm[Int, RS]] = '{ k => ${ Effects[RS2].reify[Boolean] { m(a => Effects[RS2].reflect[Boolean]('k(a))) }}} + val res : Expr[Stm[Int, RS]] = '{ k => ${ Effects[RS2].reify[Boolean] { m(a => Effects[RS2].reflect[Boolean](Expr.reduce('k)(a))) }}} println(res.show) } diff --git a/tests/run-staging/quote-ackermann-1.scala b/tests/run-staging/quote-ackermann-1.scala index 9bd0be138abc..92f81edf51b3 100644 --- a/tests/run-staging/quote-ackermann-1.scala +++ b/tests/run-staging/quote-ackermann-1.scala @@ -15,7 +15,7 @@ object Test { def ackermann(m: Int)(given QuoteContext): Expr[Int => Int] = { if (m == 0) '{ n => n + 1 } else '{ n => - def `ackermann(m-1)`(n: Int): Int = ${ackermann(m - 1)('n)} // Expr[Int => Int] applied to Expr[Int] + def `ackermann(m-1)`(n: Int): Int = ${Expr.reduce(ackermann(m - 1))('n)} // Expr[Int => Int] applied to Expr[Int] def `ackermann(m)`(n: Int): Int = if (n == 0) `ackermann(m-1)`(1) else `ackermann(m-1)`(`ackermann(m)`(n - 1)) `ackermann(m)`(n) diff --git a/tests/run-staging/quote-fun-app-1.scala b/tests/run-staging/quote-fun-app-1.scala index 564913202453..69b5a891c688 100644 --- a/tests/run-staging/quote-fun-app-1.scala +++ b/tests/run-staging/quote-fun-app-1.scala @@ -12,8 +12,8 @@ object Test { println(f(43)) } - def f1(given QuoteContext): Expr[Int => Int] = '{ n => ${f2('n)} } - def f2(given QuoteContext): Expr[Int => Int] = '{ n => ${f3('n)} } - def f3(given QuoteContext): Expr[Int => Int] = '{ n => ${f4('n)} } + def f1(given QuoteContext): Expr[Int => Int] = '{ n => ${Expr.reduce(f2)('n)} } + def f2(given QuoteContext): Expr[Int => Int] = '{ n => ${Expr.reduce(f3)('n)} } + def f3(given QuoteContext): Expr[Int => Int] = '{ n => ${Expr.reduce(f4)('n)} } def f4(given QuoteContext): Expr[Int => Int] = '{ n => n } } diff --git a/tests/run-staging/quote-function-applied-to.scala b/tests/run-staging/quote-function-applied-to.scala index dcbc4206356a..3d11d3947f36 100644 --- a/tests/run-staging/quote-function-applied-to.scala +++ b/tests/run-staging/quote-function-applied-to.scala @@ -1,56 +1,57 @@ import scala.quoted._ +import scala.quoted.given import scala.quoted.staging._ object Test { def main(args: Array[String]): Unit = { given Toolbox = Toolbox.make(getClass.getClassLoader) def show(expr: (given QuoteContext) => Expr[_]): String = withQuoteContext(expr.show) - println(show(('{ () => x(0) }).apply())) - println(show(('{ (x1: Int) => x1 }).apply('{x(1)}))) - println(show(('{ (x1: Int, x2: Int) => x1 + x2 }).apply('{x(1)}, '{x(2)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int) => x1 + x2 + x3 }).apply('{x(1)}, '{x(2)}, '{x(3)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int) => x1 + x2 + x3 + x4 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1 + x2 + x3 + x4 + x5 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1 + x2 + x3 + x4 + x5 + x6 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}))) - println(show(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 + x22 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}, '{x(22)}))) + println(show(Expr.reduce('{ () => x(0) })())) + println(show(Expr.reduce('{ (x1: Int) => x1 })('{x(1)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int) => x1 + x2 })('{x(1)}, '{x(2)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int) => x1 + x2 + x3 })('{x(1)}, '{x(2)}, '{x(3)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int) => x1 + x2 + x3 + x4 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1 + x2 + x3 + x4 + x5 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1 + x2 + x3 + x4 + x5 + x6 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}))) + println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 + x22 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}, '{x(22)}))) - println(show(('{ (given x1: Int) => x1 }).apply('{x(1)}))) - println(show(('{ (given x1: Int, x2: Int) => x1 + x2 }).apply('{x(1)}, '{x(2)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int) => x1 + x2 + x3 }).apply('{x(1)}, '{x(2)}, '{x(3)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int) => x1 + x2 + x3 + x4 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1 + x2 + x3 + x4 + x5 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1 + x2 + x3 + x4 + x5 + x6 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}))) - println(show(('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 + x22 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}, '{x(22)}))) + println(show(Expr.reduceGiven('{ (given x1: Int) => x1 })('{x(1)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int) => x1 + x2 })('{x(1)}, '{x(2)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int) => x1 + x2 + x3 })('{x(1)}, '{x(2)}, '{x(3)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int) => x1 + x2 + x3 + x4 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1 + x2 + x3 + x4 + x5 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1 + x2 + x3 + x4 + x5 + x6 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}))) + println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 + x22 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}, '{x(22)}))) } def x(i: Int): Int = i diff --git a/tests/run-staging/quote-unrolled-foreach.scala b/tests/run-staging/quote-unrolled-foreach.scala index 133e27ac6fdf..202a0d3ff9a4 100644 --- a/tests/run-staging/quote-unrolled-foreach.scala +++ b/tests/run-staging/quote-unrolled-foreach.scala @@ -79,7 +79,7 @@ object Test { var i = 0 while (i < size) { val element = ($arrRef)(i) - ${ f('element) } // Use AppliedFuntion + ${ Expr.reduce(f)('element) } // Use AppliedFuntion i += 1 } } From 88a5e460563eea17a9471c607aaa9f739f439ec3 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 25 Sep 2019 07:04:51 +0200 Subject: [PATCH 2/4] Fix doc --- docs/docs/reference/metaprogramming/macros.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/reference/metaprogramming/macros.md b/docs/docs/reference/metaprogramming/macros.md index 01fcb4113f2e..8b16a4d5410c 100644 --- a/docs/docs/reference/metaprogramming/macros.md +++ b/docs/docs/reference/metaprogramming/macros.md @@ -148,7 +148,7 @@ The definition of `Expr.reduce(f)(x)` is assumed to be functionally the same as result of beta-reducing `f(x)` if `f` is a known lambda expression. `Expr.reduce` distributes applications of `Expr` over function arrows: ```scala -Expr.reduce(_).apply: Expr[(T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) +Expr.reduce(_): Expr[(T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) ``` Its dual, let’s call it `reflect`, can be defined as follows: ```scala From 40b785cf772a1f3ecb621eb8034c075aa06f753c Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 25 Sep 2019 07:18:32 +0200 Subject: [PATCH 3/4] Improve reduce/reduceGiven docs --- library/src/scala/quoted/Expr.scala | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/library/src/scala/quoted/Expr.scala b/library/src/scala/quoted/Expr.scala index 711813587c18..e1c8be4dfe0a 100644 --- a/library/src/scala/quoted/Expr.scala +++ b/library/src/scala/quoted/Expr.scala @@ -28,13 +28,28 @@ package quoted { /** Converts a tuple `(T1, ..., Tn)` to `(Expr[T1], ..., Expr[Tn])` */ type TupleOfExpr[Tup <: Tuple] = Tuple.Map[Tup, [X] =>> (given QuoteContext) => Expr[X]] - /** Beta-reduces the function appication. Generates the an expression only containing the body of the function */ + /** `Expr.reduce(f)(x1, ..., xn)` is functionally the same as `'{($f)($x1, ..., $xn)}`, however it optimizes this call + * by returning the result of beta-reducing `f(x1, ..., xn)` if `f` is a known lambda expression. + * + * `Expr.reduce` distributes applications of `Expr` over function arrows + * ```scala + * Expr.reduce(_): Expr[(T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) + * ``` + */ def reduce[F, Args <: Tuple, R, G](f: Expr[F])(given tf: TupledFunction[F, Args => R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G = { import qctx.tasty._ tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) } - /** Beta-reduces the function appication. Generates the an expression only containing the body of the function */ + /** `Expr.reduceGiven(f)(x1, ..., xn)` is functionally the same as `'{($f)(given $x1, ..., $xn)}`, however it optimizes this call + * by returning the result of beta-reducing `f(given x1, ..., xn)` if `f` is a known lambda expression. + * + * `Expr.reduceGiven` distributes applications of `Expr` over function arrows + * ```scala + * Expr.reduceGiven(_): Expr[(given T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) + * ``` + * Note: The + */ def reduceGiven[F, Args <: Tuple, R, G](f: Expr[F])(given tf: TupledFunction[F, (given Args) => R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G = { import qctx.tasty._ tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) From 19797491d13c920bb1e7237dee666da9e019955a Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 25 Sep 2019 08:26:20 +0200 Subject: [PATCH 4/4] Rename Expr.reduce to Expr.betaReduce --- .../community-projects/xml-interpolator | 2 +- docs/docs/reference/metaprogramming/macros.md | 10 +-- library/src/scala/quoted/Expr.scala | 18 ++-- tests/pos/i6783.scala | 2 +- .../gestalt-optional-staging/Macro_1.scala | 2 +- tests/run-macros/i4734/Macro_1.scala | 2 +- tests/run-macros/i4735/Macro_1.scala | 2 +- tests/run-macros/i7008/macro_1.scala | 2 +- .../quote-inline-function/quoted_1.scala | 4 +- .../quote-matcher-symantics-2/quoted_1.scala | 2 +- .../quote-matching-optimize-1/Macro_1.scala | 6 +- .../quote-matching-optimize-2/Macro_1.scala | 6 +- .../quote-unrolled-foreach/quoted_1.scala | 2 +- .../tasty-seal-method/quoted_1.scala | 16 ++-- .../tasty-unsafe-let/quoted_1.scala | 2 +- tests/run-staging/i3876-b.scala | 4 +- tests/run-staging/i3876-c.scala | 4 +- tests/run-staging/i3876-d.scala | 4 +- tests/run-staging/i3876-e.scala | 4 +- tests/run-staging/i3876.scala | 4 +- tests/run-staging/i5144b.scala | 2 +- tests/run-staging/i6281.scala | 6 +- tests/run-staging/quote-ackermann-1.scala | 2 +- tests/run-staging/quote-fun-app-1.scala | 6 +- .../quote-function-applied-to.scala | 90 +++++++++---------- .../run-staging/quote-unrolled-foreach.scala | 2 +- 26 files changed, 103 insertions(+), 103 deletions(-) diff --git a/community-build/community-projects/xml-interpolator b/community-build/community-projects/xml-interpolator index 0bc5a4fd140b..7b2f2192e5e5 160000 --- a/community-build/community-projects/xml-interpolator +++ b/community-build/community-projects/xml-interpolator @@ -1 +1 @@ -Subproject commit 0bc5a4fd140b2af1e6e412e7ef09ce0bcfb2596f +Subproject commit 7b2f2192e5e520c0e5ce6396434bb3cd7e971d20 diff --git a/docs/docs/reference/metaprogramming/macros.md b/docs/docs/reference/metaprogramming/macros.md index 8b16a4d5410c..0ad19aa737fa 100644 --- a/docs/docs/reference/metaprogramming/macros.md +++ b/docs/docs/reference/metaprogramming/macros.md @@ -135,20 +135,20 @@ expressiveness. ### From `Expr`s to Functions and Back -The `Expr` companion object contains a `reduce` conversion that turns a tree +The `Expr` companion object contains a `betaReduce` conversion that turns a tree describing a function into a function mapping trees to trees. ```scala object Expr { ... - def reduce[...](...)(...): ... = + def betaReduce[...](...)(...): ... = ... } ``` -The definition of `Expr.reduce(f)(x)` is assumed to be functionally the same as +The definition of `Expr.betaReduce(f)(x)` is assumed to be functionally the same as `'{($f)($x)}`, however it should optimize this call by returning the result of beta-reducing `f(x)` if `f` is a known lambda expression. -`Expr.reduce` distributes applications of `Expr` over function arrows: +`Expr.betaReduce` distributes applications of `Expr` over function arrows: ```scala -Expr.reduce(_): Expr[(T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) +Expr.betaReduce(_): Expr[(T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) ``` Its dual, let’s call it `reflect`, can be defined as follows: ```scala diff --git a/library/src/scala/quoted/Expr.scala b/library/src/scala/quoted/Expr.scala index e1c8be4dfe0a..086f39cd0ae0 100644 --- a/library/src/scala/quoted/Expr.scala +++ b/library/src/scala/quoted/Expr.scala @@ -28,29 +28,29 @@ package quoted { /** Converts a tuple `(T1, ..., Tn)` to `(Expr[T1], ..., Expr[Tn])` */ type TupleOfExpr[Tup <: Tuple] = Tuple.Map[Tup, [X] =>> (given QuoteContext) => Expr[X]] - /** `Expr.reduce(f)(x1, ..., xn)` is functionally the same as `'{($f)($x1, ..., $xn)}`, however it optimizes this call + /** `Expr.betaReduce(f)(x1, ..., xn)` is functionally the same as `'{($f)($x1, ..., $xn)}`, however it optimizes this call * by returning the result of beta-reducing `f(x1, ..., xn)` if `f` is a known lambda expression. * - * `Expr.reduce` distributes applications of `Expr` over function arrows + * `Expr.betaReduce` distributes applications of `Expr` over function arrows * ```scala - * Expr.reduce(_): Expr[(T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) + * Expr.betaReduce(_): Expr[(T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) * ``` */ - def reduce[F, Args <: Tuple, R, G](f: Expr[F])(given tf: TupledFunction[F, Args => R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G = { + def betaReduce[F, Args <: Tuple, R, G](f: Expr[F])(given tf: TupledFunction[F, Args => R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G = { import qctx.tasty._ tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) } - /** `Expr.reduceGiven(f)(x1, ..., xn)` is functionally the same as `'{($f)(given $x1, ..., $xn)}`, however it optimizes this call + /** `Expr.betaReduceGiven(f)(x1, ..., xn)` is functionally the same as `'{($f)(given $x1, ..., $xn)}`, however it optimizes this call * by returning the result of beta-reducing `f(given x1, ..., xn)` if `f` is a known lambda expression. * - * `Expr.reduceGiven` distributes applications of `Expr` over function arrows + * `Expr.betaReduceGiven` distributes applications of `Expr` over function arrows * ```scala - * Expr.reduceGiven(_): Expr[(given T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) + * Expr.betaReduceGiven(_): Expr[(given T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) * ``` - * Note: The + * Note: The */ - def reduceGiven[F, Args <: Tuple, R, G](f: Expr[F])(given tf: TupledFunction[F, (given Args) => R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G = { + def betaReduceGiven[F, Args <: Tuple, R, G](f: Expr[F])(given tf: TupledFunction[F, (given Args) => R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G = { import qctx.tasty._ tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) } diff --git a/tests/pos/i6783.scala b/tests/pos/i6783.scala index dc0118fd8d7a..6aa1ff4f04a7 100644 --- a/tests/pos/i6783.scala +++ b/tests/pos/i6783.scala @@ -1,6 +1,6 @@ import scala.quoted._ -def testImpl(f: Expr[(Int, Int) => Int])(given QuoteContext): Expr[Int] = Expr.reduce(f)('{1}, '{2}) +def testImpl(f: Expr[(Int, Int) => Int])(given QuoteContext): Expr[Int] = Expr.betaReduce(f)('{1}, '{2}) inline def test(f: (Int, Int) => Int) = ${ testImpl('f) diff --git a/tests/run-macros/gestalt-optional-staging/Macro_1.scala b/tests/run-macros/gestalt-optional-staging/Macro_1.scala index 1d55cb17087d..2ed4186ea888 100644 --- a/tests/run-macros/gestalt-optional-staging/Macro_1.scala +++ b/tests/run-macros/gestalt-optional-staging/Macro_1.scala @@ -24,7 +24,7 @@ object Optional { // FIXME fix issue #5097 and enable private /*private*/ def mapImpl[A >: Null : Type, B >: Null : Type](opt: Expr[Optional[A]], f: Expr[A => B])(given QuoteContext): Expr[Optional[B]] = '{ if ($opt.isEmpty) new Optional(null) - else new Optional(${Expr.reduce(f)('{$opt.value})}) + else new Optional(${Expr.betaReduce(f)('{$opt.value})}) } } diff --git a/tests/run-macros/i4734/Macro_1.scala b/tests/run-macros/i4734/Macro_1.scala index dbc9da9d0bb4..280d43208114 100644 --- a/tests/run-macros/i4734/Macro_1.scala +++ b/tests/run-macros/i4734/Macro_1.scala @@ -15,7 +15,7 @@ object Macros { for (j <- new UnrolledRange(0, unrollSize)) '{ val index = i + $j val element = ($seq)(index) - ${ Expr.reduce(f)('element) } // or `($f)(element)` if `f` should not be inlined + ${ Expr.betaReduce(f)('element) } // or `($f)(element)` if `f` should not be inlined } } i += ${unrollSize} diff --git a/tests/run-macros/i4735/Macro_1.scala b/tests/run-macros/i4735/Macro_1.scala index 6351204a332c..41b5bb4fde3a 100644 --- a/tests/run-macros/i4735/Macro_1.scala +++ b/tests/run-macros/i4735/Macro_1.scala @@ -17,7 +17,7 @@ object Macro { ${ for (j <- new UnrolledRange(0, unrollSize)) '{ val element = ($seq)(i + ${j}) - ${Expr.reduce(f)('element)} // or `($f)(element)` if `f` should not be inlined + ${Expr.betaReduce(f)('element)} // or `($f)(element)` if `f` should not be inlined } } i += ${unrollSize} diff --git a/tests/run-macros/i7008/macro_1.scala b/tests/run-macros/i7008/macro_1.scala index 81ddaa51ece1..c2130cc60d6d 100644 --- a/tests/run-macros/i7008/macro_1.scala +++ b/tests/run-macros/i7008/macro_1.scala @@ -15,5 +15,5 @@ def mcrProxy(expr: Expr[Boolean])(given QuoteContext): Expr[Unit] = { def mcrImpl[T](func: Expr[Seq[Box[T]] => Unit], expr: Expr[T])(given ctx: QuoteContext, tt: Type[T]): Expr[Unit] = { import ctx.tasty._ val arg = Expr.ofSeq(Seq('{(Box($expr))})) - Expr.reduce(func)(arg) + Expr.betaReduce(func)(arg) } \ No newline at end of file diff --git a/tests/run-macros/quote-inline-function/quoted_1.scala b/tests/run-macros/quote-inline-function/quoted_1.scala index 2ad4a5e216eb..805d37f8bf3b 100644 --- a/tests/run-macros/quote-inline-function/quoted_1.scala +++ b/tests/run-macros/quote-inline-function/quoted_1.scala @@ -12,11 +12,11 @@ object Macros { var i = $start val j = $end while (i < j) { - ${Expr.reduce(f)('i)} + ${Expr.betaReduce(f)('i)} i += 1 } while { - ${Expr.reduce(f)('i)} + ${Expr.betaReduce(f)('i)} i += 1 i < j } do () diff --git a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala index be6d0537b4f7..2138a16f2150 100644 --- a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala @@ -72,7 +72,7 @@ object StringNum extends Symantics[String] { def value(x: Int)(given QuoteContext): Expr[String] = Expr(x.toString) def plus(x: Expr[String], y: Expr[String])(given QuoteContext): Expr[String] = '{ s"${$x} + ${$y}" } // '{ x + " + " + y } def times(x: Expr[String], y: Expr[String])(given QuoteContext): Expr[String] = '{ s"${$x} * ${$y}" } - def app(f: Expr[String => String], x: Expr[String])(given QuoteContext): Expr[String] = Expr.reduce(f)(x) + def app(f: Expr[String => String], x: Expr[String])(given QuoteContext): Expr[String] = Expr.betaReduce(f)(x) def lam(body: Expr[String] => Expr[String])(given QuoteContext): Expr[String => String] = '{ (x: String) => ${body('x)} } } diff --git a/tests/run-macros/quote-matching-optimize-1/Macro_1.scala b/tests/run-macros/quote-matching-optimize-1/Macro_1.scala index 872609abd2fb..204e6c621cf4 100644 --- a/tests/run-macros/quote-matching-optimize-1/Macro_1.scala +++ b/tests/run-macros/quote-matching-optimize-1/Macro_1.scala @@ -9,13 +9,13 @@ object Macro { def optimize(x: Expr[Any]): Expr[Any] = x match { case '{ type $t; ($ls: List[`$t`]).filter($f).filter($g) } => - optimize('{ $ls.filter(x => ${Expr.reduce(f)('x)} && ${Expr.reduce(g)('x)}) }) + optimize('{ $ls.filter(x => ${Expr.betaReduce(f)('x)} && ${Expr.betaReduce(g)('x)}) }) case '{ type $t; type $u; type $v; ($ls: List[`$t`]).map[`$u`]($f).map[`$v`]($g) } => - optimize('{ $ls.map(x => ${Expr.reduce(g)(Expr.reduce(f)('x))}) }) + optimize('{ $ls.map(x => ${Expr.betaReduce(g)(Expr.betaReduce(f)('x))}) }) case '{ type $t; ($ls: List[`$t`]).filter($f).foreach[Unit]($g) } => - optimize('{ $ls.foreach(x => if (${Expr.reduce(f)('x)}) ${Expr.reduce(g)('x)} else ()) }) + optimize('{ $ls.foreach(x => if (${Expr.betaReduce(f)('x)}) ${Expr.betaReduce(g)('x)} else ()) }) case _ => x } diff --git a/tests/run-macros/quote-matching-optimize-2/Macro_1.scala b/tests/run-macros/quote-matching-optimize-2/Macro_1.scala index 44895ecf5e4b..98dacda3df8d 100644 --- a/tests/run-macros/quote-matching-optimize-2/Macro_1.scala +++ b/tests/run-macros/quote-matching-optimize-2/Macro_1.scala @@ -11,13 +11,13 @@ object Macro { def optimize(x: Expr[Any]): Expr[Any] = x match { case '{ ($ls: List[$t]).filter($f).filter($g) } => - optimize('{ $ls.filter(x => ${Expr.reduce(f)('x)} && ${Expr.reduce(g)('x)}) }) + optimize('{ $ls.filter(x => ${Expr.betaReduce(f)('x)} && ${Expr.betaReduce(g)('x)}) }) case '{ type $u; type $v; ($ls: List[$t]).map[`$u`]($f).map[`$v`]($g) } => - optimize('{ $ls.map(x => ${Expr.reduce(g)(Expr.reduce(f)('x))}) }) + optimize('{ $ls.map(x => ${Expr.betaReduce(g)(Expr.betaReduce(f)('x))}) }) case '{ ($ls: List[$t]).filter($f).foreach[$u]($g) } => - optimize('{ $ls.foreach[Any](x => if (${Expr.reduce(f)('x)}) ${Expr.reduce(g)('x)} else ()) }) + optimize('{ $ls.foreach[Any](x => if (${Expr.betaReduce(f)('x)}) ${Expr.betaReduce(g)('x)} else ()) }) case _ => x } diff --git a/tests/run-macros/quote-unrolled-foreach/quoted_1.scala b/tests/run-macros/quote-unrolled-foreach/quoted_1.scala index dcd48c4123cf..8795c8d7247a 100644 --- a/tests/run-macros/quote-unrolled-foreach/quoted_1.scala +++ b/tests/run-macros/quote-unrolled-foreach/quoted_1.scala @@ -15,7 +15,7 @@ object Macro { println(" start loop") ${ @tailrec def loop(j: Int, acc: Expr[Unit]): Expr[Unit] = - if (j >= 0) loop(j - 1, '{ ${Expr.reduce(f)('{$seq(i + ${j})})}; $acc }) + if (j >= 0) loop(j - 1, '{ ${Expr.betaReduce(f)('{$seq(i + ${j})})}; $acc }) else acc loop(unrollSize - 1, '{}) } diff --git a/tests/run-macros/tasty-seal-method/quoted_1.scala b/tests/run-macros/tasty-seal-method/quoted_1.scala index 97bf8b000a0e..69d777485e0e 100644 --- a/tests/run-macros/tasty-seal-method/quoted_1.scala +++ b/tests/run-macros/tasty-seal-method/quoted_1.scala @@ -14,10 +14,10 @@ object Asserts { fn.tpe.widen match { case Type.IsMethodType(_) => args.size match { - case 0 => Expr.reduce(fn.seal.cast[() => Int])() - case 1 => Expr.reduce(fn.seal.cast[Int => Int])('{0}) - case 2 => Expr.reduce(fn.seal.cast[(Int, Int) => Int])('{0}, '{0}) - case 3 => Expr.reduce(fn.seal.cast[(Int, Int, Int) => Int])('{0}, '{0}, '{0}) + case 0 => Expr.betaReduce(fn.seal.cast[() => Int])() + case 1 => Expr.betaReduce(fn.seal.cast[Int => Int])('{0}) + case 2 => Expr.betaReduce(fn.seal.cast[(Int, Int) => Int])('{0}, '{0}) + case 3 => Expr.betaReduce(fn.seal.cast[(Int, Int, Int) => Int])('{0}, '{0}, '{0}) } } case _ => x @@ -35,10 +35,10 @@ object Asserts { case Apply(fn, args) => val pre = rec(fn) args.size match { - case 0 => Expr.reduce(pre.seal.cast[() => Any])().unseal - case 1 => Expr.reduce(pre.seal.cast[Int => Any])('{0}).unseal - case 2 => Expr.reduce(pre.seal.cast[(Int, Int) => Any])('{0}, '{0}).unseal - case 3 => Expr.reduce(pre.seal.cast[(Int, Int, Int) => Any])('{0}, '{0}, '{0}).unseal + case 0 => Expr.betaReduce(pre.seal.cast[() => Any])().unseal + case 1 => Expr.betaReduce(pre.seal.cast[Int => Any])('{0}).unseal + case 2 => Expr.betaReduce(pre.seal.cast[(Int, Int) => Any])('{0}, '{0}).unseal + case 3 => Expr.betaReduce(pre.seal.cast[(Int, Int, Int) => Any])('{0}, '{0}, '{0}).unseal } case _ => term } diff --git a/tests/run-macros/tasty-unsafe-let/quoted_1.scala b/tests/run-macros/tasty-unsafe-let/quoted_1.scala index 7fc9bc123a4d..7f9eff7bc59a 100644 --- a/tests/run-macros/tasty-unsafe-let/quoted_1.scala +++ b/tests/run-macros/tasty-unsafe-let/quoted_1.scala @@ -12,7 +12,7 @@ object Macros { import qctx.tasty.{let => letTerm} letTerm(rhsTerm) { rhsId => - Expr.reduce(body)(rhsId.seal.asInstanceOf[Expr[T]]).unseal // Dangerous uncheked cast! + Expr.betaReduce(body)(rhsId.seal.asInstanceOf[Expr[T]]).unseal // Dangerous uncheked cast! }.seal.cast[Unit] } diff --git a/tests/run-staging/i3876-b.scala b/tests/run-staging/i3876-b.scala index 205a44c50e7a..39d0d8b7d6dc 100644 --- a/tests/run-staging/i3876-b.scala +++ b/tests/run-staging/i3876-b.scala @@ -11,7 +11,7 @@ object Test { f } - println(run(Expr.reduce(f2)(x))) - println(withQuoteContext(Expr.reduce(f2)(x).show)) + println(run(Expr.betaReduce(f2)(x))) + println(withQuoteContext(Expr.betaReduce(f2)(x).show)) } } diff --git a/tests/run-staging/i3876-c.scala b/tests/run-staging/i3876-c.scala index fde986399147..f7b450f0b5e5 100644 --- a/tests/run-staging/i3876-c.scala +++ b/tests/run-staging/i3876-c.scala @@ -11,7 +11,7 @@ object Test { f } - println(run(Expr.reduce(f3)(x))) - println(withQuoteContext(Expr.reduce(f3)(x).show)) // TODO improve printer + println(run(Expr.betaReduce(f3)(x))) + println(withQuoteContext(Expr.betaReduce(f3)(x).show)) // TODO improve printer } } diff --git a/tests/run-staging/i3876-d.scala b/tests/run-staging/i3876-d.scala index c1a4020e9652..aa383745eb58 100644 --- a/tests/run-staging/i3876-d.scala +++ b/tests/run-staging/i3876-d.scala @@ -9,8 +9,8 @@ object Test { def f4(given QuoteContext): Expr[Int => Int] = '{ inlineLambda } - println(run(Expr.reduce(f4)(x))) - println(withQuoteContext(Expr.reduce(f4)(x).show)) + println(run(Expr.betaReduce(f4)(x))) + println(withQuoteContext(Expr.betaReduce(f4)(x).show)) } inline def inlineLambda <: Int => Int = x => x + x diff --git a/tests/run-staging/i3876-e.scala b/tests/run-staging/i3876-e.scala index 84f63986b829..4f324c943ae2 100644 --- a/tests/run-staging/i3876-e.scala +++ b/tests/run-staging/i3876-e.scala @@ -9,8 +9,8 @@ object Test { def f4(given QuoteContext): Expr[Int => Int] = '{ inlineLambda } - println(run(Expr.reduce(f4)(x))) - println(withQuoteContext(Expr.reduce(f4)(x).show)) + println(run(Expr.betaReduce(f4)(x))) + println(withQuoteContext(Expr.betaReduce(f4)(x).show)) } inline def inlineLambda <: Int => Int = x => x + x diff --git a/tests/run-staging/i3876.scala b/tests/run-staging/i3876.scala index a32b1c83fc4f..e4d0146bff3d 100644 --- a/tests/run-staging/i3876.scala +++ b/tests/run-staging/i3876.scala @@ -8,7 +8,7 @@ object Test { def f(given QuoteContext): Expr[Int => Int] = '{ (x: Int) => x + x } - println(run(Expr.reduce(f)(x))) - println(withQuoteContext(Expr.reduce(f)(x).show)) + println(run(Expr.betaReduce(f)(x))) + println(withQuoteContext(Expr.betaReduce(f)(x).show)) } } diff --git a/tests/run-staging/i5144b.scala b/tests/run-staging/i5144b.scala index 1bc59331eb43..ae270f37cb7f 100644 --- a/tests/run-staging/i5144b.scala +++ b/tests/run-staging/i5144b.scala @@ -3,7 +3,7 @@ import scala.quoted.staging._ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) - def eval1(ff: Expr[Int => Int])(given QuoteContext): Expr[Int] = Expr.reduce(ff)('{42}) + def eval1(ff: Expr[Int => Int])(given QuoteContext): Expr[Int] = Expr.betaReduce(ff)('{42}) def peval1()(given QuoteContext): Expr[Unit] = '{ def f(x: Int): Int = ${eval1('f)} diff --git a/tests/run-staging/i6281.scala b/tests/run-staging/i6281.scala index 2524d82de983..a20586881d6e 100644 --- a/tests/run-staging/i6281.scala +++ b/tests/run-staging/i6281.scala @@ -27,8 +27,8 @@ object Test extends App { } // for reify, we need type tags for E and also strangely for L. implicit def cons [E, L <: HList](given Effects[L])(given Type[E])(given Type[L])(given QuoteContext): Effects[E :: L] = new Effects[E :: L] { - def reify[A](given Type[A]) = m => '{ k => ${ Effects[L].reify[E] { m( a => Effects[L].reflect[E](Expr.reduce('k)(a))) } }} - def reflect[A](given Type[A]) = m => k => Effects[L].reflect[E] { Expr.reduce(m)('{ a => ${ Effects[L].reify[E]( k('a)) } })} + def reify[A](given Type[A]) = m => '{ k => ${ Effects[L].reify[E] { m( a => Effects[L].reflect[E](Expr.betaReduce('k)(a))) } }} + def reflect[A](given Type[A]) = m => k => Effects[L].reflect[E] { Expr.betaReduce(m)('{ a => ${ Effects[L].reify[E]( k('a)) } })} } def Effects[L <: HList](given Effects[L]): Effects[L] = summon[Effects[L]] @@ -45,7 +45,7 @@ object Test extends App { val effects = cons[Boolean, RS2](given cons[Int, String :: HNil](given cons[String, HNil](given empty))) println(effects.reify[Int] { m }.show) - val res : Expr[Stm[Int, RS]] = '{ k => ${ Effects[RS2].reify[Boolean] { m(a => Effects[RS2].reflect[Boolean](Expr.reduce('k)(a))) }}} + val res : Expr[Stm[Int, RS]] = '{ k => ${ Effects[RS2].reify[Boolean] { m(a => Effects[RS2].reflect[Boolean](Expr.betaReduce('k)(a))) }}} println(res.show) } diff --git a/tests/run-staging/quote-ackermann-1.scala b/tests/run-staging/quote-ackermann-1.scala index 92f81edf51b3..f1e5a5424d85 100644 --- a/tests/run-staging/quote-ackermann-1.scala +++ b/tests/run-staging/quote-ackermann-1.scala @@ -15,7 +15,7 @@ object Test { def ackermann(m: Int)(given QuoteContext): Expr[Int => Int] = { if (m == 0) '{ n => n + 1 } else '{ n => - def `ackermann(m-1)`(n: Int): Int = ${Expr.reduce(ackermann(m - 1))('n)} // Expr[Int => Int] applied to Expr[Int] + def `ackermann(m-1)`(n: Int): Int = ${Expr.betaReduce(ackermann(m - 1))('n)} // Expr[Int => Int] applied to Expr[Int] def `ackermann(m)`(n: Int): Int = if (n == 0) `ackermann(m-1)`(1) else `ackermann(m-1)`(`ackermann(m)`(n - 1)) `ackermann(m)`(n) diff --git a/tests/run-staging/quote-fun-app-1.scala b/tests/run-staging/quote-fun-app-1.scala index 69b5a891c688..0b052319cf22 100644 --- a/tests/run-staging/quote-fun-app-1.scala +++ b/tests/run-staging/quote-fun-app-1.scala @@ -12,8 +12,8 @@ object Test { println(f(43)) } - def f1(given QuoteContext): Expr[Int => Int] = '{ n => ${Expr.reduce(f2)('n)} } - def f2(given QuoteContext): Expr[Int => Int] = '{ n => ${Expr.reduce(f3)('n)} } - def f3(given QuoteContext): Expr[Int => Int] = '{ n => ${Expr.reduce(f4)('n)} } + def f1(given QuoteContext): Expr[Int => Int] = '{ n => ${Expr.betaReduce(f2)('n)} } + def f2(given QuoteContext): Expr[Int => Int] = '{ n => ${Expr.betaReduce(f3)('n)} } + def f3(given QuoteContext): Expr[Int => Int] = '{ n => ${Expr.betaReduce(f4)('n)} } def f4(given QuoteContext): Expr[Int => Int] = '{ n => n } } diff --git a/tests/run-staging/quote-function-applied-to.scala b/tests/run-staging/quote-function-applied-to.scala index 3d11d3947f36..94af9f477454 100644 --- a/tests/run-staging/quote-function-applied-to.scala +++ b/tests/run-staging/quote-function-applied-to.scala @@ -6,52 +6,52 @@ object Test { def main(args: Array[String]): Unit = { given Toolbox = Toolbox.make(getClass.getClassLoader) def show(expr: (given QuoteContext) => Expr[_]): String = withQuoteContext(expr.show) - println(show(Expr.reduce('{ () => x(0) })())) - println(show(Expr.reduce('{ (x1: Int) => x1 })('{x(1)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int) => x1 + x2 })('{x(1)}, '{x(2)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int) => x1 + x2 + x3 })('{x(1)}, '{x(2)}, '{x(3)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int) => x1 + x2 + x3 + x4 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1 + x2 + x3 + x4 + x5 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1 + x2 + x3 + x4 + x5 + x6 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}))) - println(show(Expr.reduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 + x22 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}, '{x(22)}))) + println(show(Expr.betaReduce('{ () => x(0) })())) + println(show(Expr.betaReduce('{ (x1: Int) => x1 })('{x(1)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int) => x1 + x2 })('{x(1)}, '{x(2)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int) => x1 + x2 + x3 })('{x(1)}, '{x(2)}, '{x(3)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int) => x1 + x2 + x3 + x4 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1 + x2 + x3 + x4 + x5 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1 + x2 + x3 + x4 + x5 + x6 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}))) + println(show(Expr.betaReduce('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 + x22 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}, '{x(22)}))) - println(show(Expr.reduceGiven('{ (given x1: Int) => x1 })('{x(1)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int) => x1 + x2 })('{x(1)}, '{x(2)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int) => x1 + x2 + x3 })('{x(1)}, '{x(2)}, '{x(3)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int) => x1 + x2 + x3 + x4 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1 + x2 + x3 + x4 + x5 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1 + x2 + x3 + x4 + x5 + x6 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}))) - println(show(Expr.reduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 + x22 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}, '{x(22)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int) => x1 })('{x(1)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int) => x1 + x2 })('{x(1)}, '{x(2)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int) => x1 + x2 + x3 })('{x(1)}, '{x(2)}, '{x(3)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int) => x1 + x2 + x3 + x4 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1 + x2 + x3 + x4 + x5 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1 + x2 + x3 + x4 + x5 + x6 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}))) + println(show(Expr.betaReduceGiven('{ (given x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 + x22 })('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}, '{x(22)}))) } def x(i: Int): Int = i diff --git a/tests/run-staging/quote-unrolled-foreach.scala b/tests/run-staging/quote-unrolled-foreach.scala index 202a0d3ff9a4..fbc4acb46645 100644 --- a/tests/run-staging/quote-unrolled-foreach.scala +++ b/tests/run-staging/quote-unrolled-foreach.scala @@ -79,7 +79,7 @@ object Test { var i = 0 while (i < size) { val element = ($arrRef)(i) - ${ Expr.reduce(f)('element) } // Use AppliedFuntion + ${ Expr.betaReduce(f)('element) } // Use AppliedFuntion i += 1 } }