From e12e142200a05d3866f789417362f50578966492 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Mon, 3 Nov 2025 12:01:31 +0100 Subject: [PATCH 1/8] Lazy For() Comprehension --- vavr/generator/Generator.scala | 146 + vavr/src-gen/main/java/io/vavr/API.java | 3654 +++++++++++++++++++++++ 2 files changed, 3800 insertions(+) diff --git a/vavr/generator/Generator.scala b/vavr/generator/Generator.scala index 7bf4464945..8fb823d49a 100644 --- a/vavr/generator/Generator.scala +++ b/vavr/generator/Generator.scala @@ -743,6 +743,150 @@ def generateMainClasses(): Unit = { """ } + def genLazyFor(im: ImportManager, packageName: String, className: String): String = { + xs""" + ${ + monadicTypesFor + .filterNot(_ == "Iterable") + .gen(mtype => (2 to N).gen(i => { + val forClassName = s"ForLazy$i$mtype" + val isComplex = monadicTypesThatNeedParameter.contains(mtype) + val parameterInset = if (isComplex) "L, " else "" + val generics = parameterInset + (1 to i).gen(j => s"T$j")(", ") + + val params = (1 to i).gen { j => + if (j == 1) + s"$mtype<${parameterInset}T1> ts1" + else { + val inputTypes = (1 until j).gen(k => s"T$k")(", ") + s"Function${j - 1}<$inputTypes, $mtype<${parameterInset}T$j>> ts$j" + } + }(", ") + + val ctorArgs = (1 to i).gen(j => s"ts$j")(", ") + + xs""" + /$javadoc + * Creates a lazy {@code For}-comprehension over ${i.numerus(mtype)}. + * + *

The first argument ({@code ts1}) is the initial ${mtype}. Each subsequent + * argument ({@code ts2} .. {@code ts$i}) is a function that receives all values + * bound so far and returns the next ${mtype}. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + ${(0 to i).gen(j => if (j == 0) "*" else s"* @param ts$j the ${j.ordinal} ${mtype}")("\n")} + ${if (isComplex) s"* @param the common left-hand type of all ${mtype}s\n" else ""} + ${(1 to i).gen(j => s"* @param the component type of the ${j.ordinal} ${mtype}")("\n")} + * @return a new {@code $forClassName} builder of arity $i + * @throws NullPointerException if any argument is {@code null} + */ + public static <$generics> $forClassName<$generics> For($params) { + ${(1 to i).gen(j => xs"""$Objects.requireNonNull(ts$j, "ts$j is null");""")("\n")} + return new $forClassName<>($ctorArgs); + } + """ + })("\n\n"))("\n\n") + } + + ${ + monadicTypesFor + .filterNot(_ == "Iterable") + .gen(mtype => (2 to N).gen(i => { + val rtype = mtype + val forClassName = s"ForLazy$i$mtype" + val parameterInset = if (monadicTypesThatNeedParameter.contains(mtype)) "L, " else "" + val generics = parameterInset + (1 to i).gen(j => s"T$j")(", ") + val functionType = i match { + case 2 => BiFunctionType + case _ => s"Function$i" + } + val args = (1 to i).gen(j => s"? super T$j")(", ") + + val fields = (1 to i).gen { j => + if (j == 1) + s"private final $mtype<${parameterInset}T1> ts1;" + else { + val inputTypes = (1 until j).gen(k => s"T$k")(", ") + s"private final Function${j - 1}<$inputTypes, $mtype<${parameterInset}T$j>> ts$j;" + } + }("\n") + + val ctorParams = (1 to i).gen { j => + if (j == 1) + s"$mtype<${parameterInset}T1> ts1" + else { + val inputTypes = (1 until j).gen(k => s"T$k")(", ") + s"Function${j - 1}<$inputTypes, $mtype<${parameterInset}T$j>> ts$j" + } + }(", ") + + val assignments = (1 to i).gen(j => s"this.ts$j = ts$j;")("\n") + + val yieldBody = { + def nestedLambda(j: Int): String = { + val base = " " + val indent = " " * j + if (j == i) { + val argsList = (1 to i).map(k => s"t$k").mkString(", ") + val inputArgs = (1 until i).map(k => s"t$k").mkString(", ") + s"ts$i.apply($inputArgs).map(t$i -> f.apply($argsList))" + } else if (j == 1) { + s"ts1.flatMap(t1 -> {\n" + + s"${base}${indent} return ${nestedLambda(j + 1)};\n" + + s"${base}${indent}})" + } else { + val inputArgs = (1 until j).map(k => s"t$k").mkString(", ") + s"ts$j.apply($inputArgs).flatMap(t$j -> {\n" + + s"${base}${indent} return ${nestedLambda(j + 1)};\n" + + s"${base}${indent}})" + } + } + + nestedLambda(1) + } + + xs""" + /$javadoc + * A lazily evaluated {@code For}-comprehension with ${i.numerus(mtype)}. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying ${i.plural(mtype)} are only + * traversed when {@code yield(...)} is invoked.

+ * + ${if (monadicTypesThatNeedParameter.contains(mtype)) s"* @param the common left-hand type of all ${mtype}s\n" else ""} + ${(1 to i).gen(j => s"* @param the component type of the ${j.ordinal} ${mtype}")("\n")} + */ + public static class $forClassName<$generics> { + + $fields + + private $forClassName($ctorParams) { + $assignments + } + + /$javadoc + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying ${i.plural(mtype)} by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code $rtype} + * @return an {@code $rtype} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public $rtype<${parameterInset}R> yield($functionType<$args, ? extends R> f) { + $Objects.requireNonNull(f, "f is null"); + return $yieldBody; + } + } + """ + })("\n\n"))("\n\n") + } + """ + } + + def genFor(im: ImportManager, packageName: String, className: String): String = { xs""" // @@ -1440,6 +1584,8 @@ def generateMainClasses(): Unit = { ${genFor(im, packageName, className)} + ${genLazyFor(im, packageName, className)} + ${genMatch(im, packageName, className)} } """ diff --git a/vavr/src-gen/main/java/io/vavr/API.java b/vavr/src-gen/main/java/io/vavr/API.java index 99c8a182b1..94fd4f1642 100644 --- a/vavr/src-gen/main/java/io/vavr/API.java +++ b/vavr/src-gen/main/java/io/vavr/API.java @@ -5740,6 +5740,3660 @@ public Validation yield(Function8The first argument ({@code ts1}) is the initial Option. Each subsequent + * argument ({@code ts2} .. {@code ts2}) is a function that receives all values + * bound so far and returns the next Option. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Option + * @param ts2 the 2nd Option + + * @param the component type of the 1st Option + * @param the component type of the 2nd Option + * @return a new {@code ForLazy2Option} builder of arity 2 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy2Option For(Option ts1, Function1> ts2) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + return new ForLazy2Option<>(ts1, ts2); + } + + /** + * Creates a lazy {@code For}-comprehension over three Options. + * + *

The first argument ({@code ts1}) is the initial Option. Each subsequent + * argument ({@code ts2} .. {@code ts3}) is a function that receives all values + * bound so far and returns the next Option. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Option + * @param ts2 the 2nd Option + * @param ts3 the 3rd Option + + * @param the component type of the 1st Option + * @param the component type of the 2nd Option + * @param the component type of the 3rd Option + * @return a new {@code ForLazy3Option} builder of arity 3 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy3Option For(Option ts1, Function1> ts2, Function2> ts3) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + return new ForLazy3Option<>(ts1, ts2, ts3); + } + + /** + * Creates a lazy {@code For}-comprehension over 4 Options. + * + *

The first argument ({@code ts1}) is the initial Option. Each subsequent + * argument ({@code ts2} .. {@code ts4}) is a function that receives all values + * bound so far and returns the next Option. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Option + * @param ts2 the 2nd Option + * @param ts3 the 3rd Option + * @param ts4 the 4th Option + + * @param the component type of the 1st Option + * @param the component type of the 2nd Option + * @param the component type of the 3rd Option + * @param the component type of the 4th Option + * @return a new {@code ForLazy4Option} builder of arity 4 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy4Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + return new ForLazy4Option<>(ts1, ts2, ts3, ts4); + } + + /** + * Creates a lazy {@code For}-comprehension over 5 Options. + * + *

The first argument ({@code ts1}) is the initial Option. Each subsequent + * argument ({@code ts2} .. {@code ts5}) is a function that receives all values + * bound so far and returns the next Option. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Option + * @param ts2 the 2nd Option + * @param ts3 the 3rd Option + * @param ts4 the 4th Option + * @param ts5 the 5th Option + + * @param the component type of the 1st Option + * @param the component type of the 2nd Option + * @param the component type of the 3rd Option + * @param the component type of the 4th Option + * @param the component type of the 5th Option + * @return a new {@code ForLazy5Option} builder of arity 5 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy5Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + return new ForLazy5Option<>(ts1, ts2, ts3, ts4, ts5); + } + + /** + * Creates a lazy {@code For}-comprehension over 6 Options. + * + *

The first argument ({@code ts1}) is the initial Option. Each subsequent + * argument ({@code ts2} .. {@code ts6}) is a function that receives all values + * bound so far and returns the next Option. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Option + * @param ts2 the 2nd Option + * @param ts3 the 3rd Option + * @param ts4 the 4th Option + * @param ts5 the 5th Option + * @param ts6 the 6th Option + + * @param the component type of the 1st Option + * @param the component type of the 2nd Option + * @param the component type of the 3rd Option + * @param the component type of the 4th Option + * @param the component type of the 5th Option + * @param the component type of the 6th Option + * @return a new {@code ForLazy6Option} builder of arity 6 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy6Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + return new ForLazy6Option<>(ts1, ts2, ts3, ts4, ts5, ts6); + } + + /** + * Creates a lazy {@code For}-comprehension over 7 Options. + * + *

The first argument ({@code ts1}) is the initial Option. Each subsequent + * argument ({@code ts2} .. {@code ts7}) is a function that receives all values + * bound so far and returns the next Option. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Option + * @param ts2 the 2nd Option + * @param ts3 the 3rd Option + * @param ts4 the 4th Option + * @param ts5 the 5th Option + * @param ts6 the 6th Option + * @param ts7 the 7th Option + + * @param the component type of the 1st Option + * @param the component type of the 2nd Option + * @param the component type of the 3rd Option + * @param the component type of the 4th Option + * @param the component type of the 5th Option + * @param the component type of the 6th Option + * @param the component type of the 7th Option + * @return a new {@code ForLazy7Option} builder of arity 7 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy7Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + Objects.requireNonNull(ts7, "ts7 is null"); + return new ForLazy7Option<>(ts1, ts2, ts3, ts4, ts5, ts6, ts7); + } + + /** + * Creates a lazy {@code For}-comprehension over 8 Options. + * + *

The first argument ({@code ts1}) is the initial Option. Each subsequent + * argument ({@code ts2} .. {@code ts8}) is a function that receives all values + * bound so far and returns the next Option. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Option + * @param ts2 the 2nd Option + * @param ts3 the 3rd Option + * @param ts4 the 4th Option + * @param ts5 the 5th Option + * @param ts6 the 6th Option + * @param ts7 the 7th Option + * @param ts8 the 8th Option + + * @param the component type of the 1st Option + * @param the component type of the 2nd Option + * @param the component type of the 3rd Option + * @param the component type of the 4th Option + * @param the component type of the 5th Option + * @param the component type of the 6th Option + * @param the component type of the 7th Option + * @param the component type of the 8th Option + * @return a new {@code ForLazy8Option} builder of arity 8 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy8Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + Objects.requireNonNull(ts7, "ts7 is null"); + Objects.requireNonNull(ts8, "ts8 is null"); + return new ForLazy8Option<>(ts1, ts2, ts3, ts4, ts5, ts6, ts7, ts8); + } + + /** + * Creates a lazy {@code For}-comprehension over two Futures. + * + *

The first argument ({@code ts1}) is the initial Future. Each subsequent + * argument ({@code ts2} .. {@code ts2}) is a function that receives all values + * bound so far and returns the next Future. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Future + * @param ts2 the 2nd Future + + * @param the component type of the 1st Future + * @param the component type of the 2nd Future + * @return a new {@code ForLazy2Future} builder of arity 2 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy2Future For(Future ts1, Function1> ts2) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + return new ForLazy2Future<>(ts1, ts2); + } + + /** + * Creates a lazy {@code For}-comprehension over three Futures. + * + *

The first argument ({@code ts1}) is the initial Future. Each subsequent + * argument ({@code ts2} .. {@code ts3}) is a function that receives all values + * bound so far and returns the next Future. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Future + * @param ts2 the 2nd Future + * @param ts3 the 3rd Future + + * @param the component type of the 1st Future + * @param the component type of the 2nd Future + * @param the component type of the 3rd Future + * @return a new {@code ForLazy3Future} builder of arity 3 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy3Future For(Future ts1, Function1> ts2, Function2> ts3) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + return new ForLazy3Future<>(ts1, ts2, ts3); + } + + /** + * Creates a lazy {@code For}-comprehension over 4 Futures. + * + *

The first argument ({@code ts1}) is the initial Future. Each subsequent + * argument ({@code ts2} .. {@code ts4}) is a function that receives all values + * bound so far and returns the next Future. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Future + * @param ts2 the 2nd Future + * @param ts3 the 3rd Future + * @param ts4 the 4th Future + + * @param the component type of the 1st Future + * @param the component type of the 2nd Future + * @param the component type of the 3rd Future + * @param the component type of the 4th Future + * @return a new {@code ForLazy4Future} builder of arity 4 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy4Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + return new ForLazy4Future<>(ts1, ts2, ts3, ts4); + } + + /** + * Creates a lazy {@code For}-comprehension over 5 Futures. + * + *

The first argument ({@code ts1}) is the initial Future. Each subsequent + * argument ({@code ts2} .. {@code ts5}) is a function that receives all values + * bound so far and returns the next Future. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Future + * @param ts2 the 2nd Future + * @param ts3 the 3rd Future + * @param ts4 the 4th Future + * @param ts5 the 5th Future + + * @param the component type of the 1st Future + * @param the component type of the 2nd Future + * @param the component type of the 3rd Future + * @param the component type of the 4th Future + * @param the component type of the 5th Future + * @return a new {@code ForLazy5Future} builder of arity 5 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy5Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + return new ForLazy5Future<>(ts1, ts2, ts3, ts4, ts5); + } + + /** + * Creates a lazy {@code For}-comprehension over 6 Futures. + * + *

The first argument ({@code ts1}) is the initial Future. Each subsequent + * argument ({@code ts2} .. {@code ts6}) is a function that receives all values + * bound so far and returns the next Future. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Future + * @param ts2 the 2nd Future + * @param ts3 the 3rd Future + * @param ts4 the 4th Future + * @param ts5 the 5th Future + * @param ts6 the 6th Future + + * @param the component type of the 1st Future + * @param the component type of the 2nd Future + * @param the component type of the 3rd Future + * @param the component type of the 4th Future + * @param the component type of the 5th Future + * @param the component type of the 6th Future + * @return a new {@code ForLazy6Future} builder of arity 6 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy6Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + return new ForLazy6Future<>(ts1, ts2, ts3, ts4, ts5, ts6); + } + + /** + * Creates a lazy {@code For}-comprehension over 7 Futures. + * + *

The first argument ({@code ts1}) is the initial Future. Each subsequent + * argument ({@code ts2} .. {@code ts7}) is a function that receives all values + * bound so far and returns the next Future. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Future + * @param ts2 the 2nd Future + * @param ts3 the 3rd Future + * @param ts4 the 4th Future + * @param ts5 the 5th Future + * @param ts6 the 6th Future + * @param ts7 the 7th Future + + * @param the component type of the 1st Future + * @param the component type of the 2nd Future + * @param the component type of the 3rd Future + * @param the component type of the 4th Future + * @param the component type of the 5th Future + * @param the component type of the 6th Future + * @param the component type of the 7th Future + * @return a new {@code ForLazy7Future} builder of arity 7 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy7Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + Objects.requireNonNull(ts7, "ts7 is null"); + return new ForLazy7Future<>(ts1, ts2, ts3, ts4, ts5, ts6, ts7); + } + + /** + * Creates a lazy {@code For}-comprehension over 8 Futures. + * + *

The first argument ({@code ts1}) is the initial Future. Each subsequent + * argument ({@code ts2} .. {@code ts8}) is a function that receives all values + * bound so far and returns the next Future. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Future + * @param ts2 the 2nd Future + * @param ts3 the 3rd Future + * @param ts4 the 4th Future + * @param ts5 the 5th Future + * @param ts6 the 6th Future + * @param ts7 the 7th Future + * @param ts8 the 8th Future + + * @param the component type of the 1st Future + * @param the component type of the 2nd Future + * @param the component type of the 3rd Future + * @param the component type of the 4th Future + * @param the component type of the 5th Future + * @param the component type of the 6th Future + * @param the component type of the 7th Future + * @param the component type of the 8th Future + * @return a new {@code ForLazy8Future} builder of arity 8 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy8Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + Objects.requireNonNull(ts7, "ts7 is null"); + Objects.requireNonNull(ts8, "ts8 is null"); + return new ForLazy8Future<>(ts1, ts2, ts3, ts4, ts5, ts6, ts7, ts8); + } + + /** + * Creates a lazy {@code For}-comprehension over two Trys. + * + *

The first argument ({@code ts1}) is the initial Try. Each subsequent + * argument ({@code ts2} .. {@code ts2}) is a function that receives all values + * bound so far and returns the next Try. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Try + * @param ts2 the 2nd Try + + * @param the component type of the 1st Try + * @param the component type of the 2nd Try + * @return a new {@code ForLazy2Try} builder of arity 2 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy2Try For(Try ts1, Function1> ts2) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + return new ForLazy2Try<>(ts1, ts2); + } + + /** + * Creates a lazy {@code For}-comprehension over three Trys. + * + *

The first argument ({@code ts1}) is the initial Try. Each subsequent + * argument ({@code ts2} .. {@code ts3}) is a function that receives all values + * bound so far and returns the next Try. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Try + * @param ts2 the 2nd Try + * @param ts3 the 3rd Try + + * @param the component type of the 1st Try + * @param the component type of the 2nd Try + * @param the component type of the 3rd Try + * @return a new {@code ForLazy3Try} builder of arity 3 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy3Try For(Try ts1, Function1> ts2, Function2> ts3) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + return new ForLazy3Try<>(ts1, ts2, ts3); + } + + /** + * Creates a lazy {@code For}-comprehension over 4 Trys. + * + *

The first argument ({@code ts1}) is the initial Try. Each subsequent + * argument ({@code ts2} .. {@code ts4}) is a function that receives all values + * bound so far and returns the next Try. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Try + * @param ts2 the 2nd Try + * @param ts3 the 3rd Try + * @param ts4 the 4th Try + + * @param the component type of the 1st Try + * @param the component type of the 2nd Try + * @param the component type of the 3rd Try + * @param the component type of the 4th Try + * @return a new {@code ForLazy4Try} builder of arity 4 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy4Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + return new ForLazy4Try<>(ts1, ts2, ts3, ts4); + } + + /** + * Creates a lazy {@code For}-comprehension over 5 Trys. + * + *

The first argument ({@code ts1}) is the initial Try. Each subsequent + * argument ({@code ts2} .. {@code ts5}) is a function that receives all values + * bound so far and returns the next Try. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Try + * @param ts2 the 2nd Try + * @param ts3 the 3rd Try + * @param ts4 the 4th Try + * @param ts5 the 5th Try + + * @param the component type of the 1st Try + * @param the component type of the 2nd Try + * @param the component type of the 3rd Try + * @param the component type of the 4th Try + * @param the component type of the 5th Try + * @return a new {@code ForLazy5Try} builder of arity 5 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy5Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + return new ForLazy5Try<>(ts1, ts2, ts3, ts4, ts5); + } + + /** + * Creates a lazy {@code For}-comprehension over 6 Trys. + * + *

The first argument ({@code ts1}) is the initial Try. Each subsequent + * argument ({@code ts2} .. {@code ts6}) is a function that receives all values + * bound so far and returns the next Try. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Try + * @param ts2 the 2nd Try + * @param ts3 the 3rd Try + * @param ts4 the 4th Try + * @param ts5 the 5th Try + * @param ts6 the 6th Try + + * @param the component type of the 1st Try + * @param the component type of the 2nd Try + * @param the component type of the 3rd Try + * @param the component type of the 4th Try + * @param the component type of the 5th Try + * @param the component type of the 6th Try + * @return a new {@code ForLazy6Try} builder of arity 6 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy6Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + return new ForLazy6Try<>(ts1, ts2, ts3, ts4, ts5, ts6); + } + + /** + * Creates a lazy {@code For}-comprehension over 7 Trys. + * + *

The first argument ({@code ts1}) is the initial Try. Each subsequent + * argument ({@code ts2} .. {@code ts7}) is a function that receives all values + * bound so far and returns the next Try. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Try + * @param ts2 the 2nd Try + * @param ts3 the 3rd Try + * @param ts4 the 4th Try + * @param ts5 the 5th Try + * @param ts6 the 6th Try + * @param ts7 the 7th Try + + * @param the component type of the 1st Try + * @param the component type of the 2nd Try + * @param the component type of the 3rd Try + * @param the component type of the 4th Try + * @param the component type of the 5th Try + * @param the component type of the 6th Try + * @param the component type of the 7th Try + * @return a new {@code ForLazy7Try} builder of arity 7 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy7Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + Objects.requireNonNull(ts7, "ts7 is null"); + return new ForLazy7Try<>(ts1, ts2, ts3, ts4, ts5, ts6, ts7); + } + + /** + * Creates a lazy {@code For}-comprehension over 8 Trys. + * + *

The first argument ({@code ts1}) is the initial Try. Each subsequent + * argument ({@code ts2} .. {@code ts8}) is a function that receives all values + * bound so far and returns the next Try. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Try + * @param ts2 the 2nd Try + * @param ts3 the 3rd Try + * @param ts4 the 4th Try + * @param ts5 the 5th Try + * @param ts6 the 6th Try + * @param ts7 the 7th Try + * @param ts8 the 8th Try + + * @param the component type of the 1st Try + * @param the component type of the 2nd Try + * @param the component type of the 3rd Try + * @param the component type of the 4th Try + * @param the component type of the 5th Try + * @param the component type of the 6th Try + * @param the component type of the 7th Try + * @param the component type of the 8th Try + * @return a new {@code ForLazy8Try} builder of arity 8 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy8Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + Objects.requireNonNull(ts7, "ts7 is null"); + Objects.requireNonNull(ts8, "ts8 is null"); + return new ForLazy8Try<>(ts1, ts2, ts3, ts4, ts5, ts6, ts7, ts8); + } + + /** + * Creates a lazy {@code For}-comprehension over two Lists. + * + *

The first argument ({@code ts1}) is the initial List. Each subsequent + * argument ({@code ts2} .. {@code ts2}) is a function that receives all values + * bound so far and returns the next List. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st List + * @param ts2 the 2nd List + + * @param the component type of the 1st List + * @param the component type of the 2nd List + * @return a new {@code ForLazy2List} builder of arity 2 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy2List For(List ts1, Function1> ts2) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + return new ForLazy2List<>(ts1, ts2); + } + + /** + * Creates a lazy {@code For}-comprehension over three Lists. + * + *

The first argument ({@code ts1}) is the initial List. Each subsequent + * argument ({@code ts2} .. {@code ts3}) is a function that receives all values + * bound so far and returns the next List. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st List + * @param ts2 the 2nd List + * @param ts3 the 3rd List + + * @param the component type of the 1st List + * @param the component type of the 2nd List + * @param the component type of the 3rd List + * @return a new {@code ForLazy3List} builder of arity 3 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy3List For(List ts1, Function1> ts2, Function2> ts3) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + return new ForLazy3List<>(ts1, ts2, ts3); + } + + /** + * Creates a lazy {@code For}-comprehension over 4 Lists. + * + *

The first argument ({@code ts1}) is the initial List. Each subsequent + * argument ({@code ts2} .. {@code ts4}) is a function that receives all values + * bound so far and returns the next List. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st List + * @param ts2 the 2nd List + * @param ts3 the 3rd List + * @param ts4 the 4th List + + * @param the component type of the 1st List + * @param the component type of the 2nd List + * @param the component type of the 3rd List + * @param the component type of the 4th List + * @return a new {@code ForLazy4List} builder of arity 4 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy4List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + return new ForLazy4List<>(ts1, ts2, ts3, ts4); + } + + /** + * Creates a lazy {@code For}-comprehension over 5 Lists. + * + *

The first argument ({@code ts1}) is the initial List. Each subsequent + * argument ({@code ts2} .. {@code ts5}) is a function that receives all values + * bound so far and returns the next List. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st List + * @param ts2 the 2nd List + * @param ts3 the 3rd List + * @param ts4 the 4th List + * @param ts5 the 5th List + + * @param the component type of the 1st List + * @param the component type of the 2nd List + * @param the component type of the 3rd List + * @param the component type of the 4th List + * @param the component type of the 5th List + * @return a new {@code ForLazy5List} builder of arity 5 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy5List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + return new ForLazy5List<>(ts1, ts2, ts3, ts4, ts5); + } + + /** + * Creates a lazy {@code For}-comprehension over 6 Lists. + * + *

The first argument ({@code ts1}) is the initial List. Each subsequent + * argument ({@code ts2} .. {@code ts6}) is a function that receives all values + * bound so far and returns the next List. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st List + * @param ts2 the 2nd List + * @param ts3 the 3rd List + * @param ts4 the 4th List + * @param ts5 the 5th List + * @param ts6 the 6th List + + * @param the component type of the 1st List + * @param the component type of the 2nd List + * @param the component type of the 3rd List + * @param the component type of the 4th List + * @param the component type of the 5th List + * @param the component type of the 6th List + * @return a new {@code ForLazy6List} builder of arity 6 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy6List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + return new ForLazy6List<>(ts1, ts2, ts3, ts4, ts5, ts6); + } + + /** + * Creates a lazy {@code For}-comprehension over 7 Lists. + * + *

The first argument ({@code ts1}) is the initial List. Each subsequent + * argument ({@code ts2} .. {@code ts7}) is a function that receives all values + * bound so far and returns the next List. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st List + * @param ts2 the 2nd List + * @param ts3 the 3rd List + * @param ts4 the 4th List + * @param ts5 the 5th List + * @param ts6 the 6th List + * @param ts7 the 7th List + + * @param the component type of the 1st List + * @param the component type of the 2nd List + * @param the component type of the 3rd List + * @param the component type of the 4th List + * @param the component type of the 5th List + * @param the component type of the 6th List + * @param the component type of the 7th List + * @return a new {@code ForLazy7List} builder of arity 7 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy7List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + Objects.requireNonNull(ts7, "ts7 is null"); + return new ForLazy7List<>(ts1, ts2, ts3, ts4, ts5, ts6, ts7); + } + + /** + * Creates a lazy {@code For}-comprehension over 8 Lists. + * + *

The first argument ({@code ts1}) is the initial List. Each subsequent + * argument ({@code ts2} .. {@code ts8}) is a function that receives all values + * bound so far and returns the next List. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st List + * @param ts2 the 2nd List + * @param ts3 the 3rd List + * @param ts4 the 4th List + * @param ts5 the 5th List + * @param ts6 the 6th List + * @param ts7 the 7th List + * @param ts8 the 8th List + + * @param the component type of the 1st List + * @param the component type of the 2nd List + * @param the component type of the 3rd List + * @param the component type of the 4th List + * @param the component type of the 5th List + * @param the component type of the 6th List + * @param the component type of the 7th List + * @param the component type of the 8th List + * @return a new {@code ForLazy8List} builder of arity 8 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy8List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + Objects.requireNonNull(ts7, "ts7 is null"); + Objects.requireNonNull(ts8, "ts8 is null"); + return new ForLazy8List<>(ts1, ts2, ts3, ts4, ts5, ts6, ts7, ts8); + } + + /** + * Creates a lazy {@code For}-comprehension over two Eithers. + * + *

The first argument ({@code ts1}) is the initial Either. Each subsequent + * argument ({@code ts2} .. {@code ts2}) is a function that receives all values + * bound so far and returns the next Either. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Either + * @param ts2 the 2nd Either + * @param the common left-hand type of all Eithers + * @param the component type of the 1st Either + * @param the component type of the 2nd Either + * @return a new {@code ForLazy2Either} builder of arity 2 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy2Either For(Either ts1, Function1> ts2) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + return new ForLazy2Either<>(ts1, ts2); + } + + /** + * Creates a lazy {@code For}-comprehension over three Eithers. + * + *

The first argument ({@code ts1}) is the initial Either. Each subsequent + * argument ({@code ts2} .. {@code ts3}) is a function that receives all values + * bound so far and returns the next Either. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Either + * @param ts2 the 2nd Either + * @param ts3 the 3rd Either + * @param the common left-hand type of all Eithers + * @param the component type of the 1st Either + * @param the component type of the 2nd Either + * @param the component type of the 3rd Either + * @return a new {@code ForLazy3Either} builder of arity 3 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy3Either For(Either ts1, Function1> ts2, Function2> ts3) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + return new ForLazy3Either<>(ts1, ts2, ts3); + } + + /** + * Creates a lazy {@code For}-comprehension over 4 Eithers. + * + *

The first argument ({@code ts1}) is the initial Either. Each subsequent + * argument ({@code ts2} .. {@code ts4}) is a function that receives all values + * bound so far and returns the next Either. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Either + * @param ts2 the 2nd Either + * @param ts3 the 3rd Either + * @param ts4 the 4th Either + * @param the common left-hand type of all Eithers + * @param the component type of the 1st Either + * @param the component type of the 2nd Either + * @param the component type of the 3rd Either + * @param the component type of the 4th Either + * @return a new {@code ForLazy4Either} builder of arity 4 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy4Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + return new ForLazy4Either<>(ts1, ts2, ts3, ts4); + } + + /** + * Creates a lazy {@code For}-comprehension over 5 Eithers. + * + *

The first argument ({@code ts1}) is the initial Either. Each subsequent + * argument ({@code ts2} .. {@code ts5}) is a function that receives all values + * bound so far and returns the next Either. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Either + * @param ts2 the 2nd Either + * @param ts3 the 3rd Either + * @param ts4 the 4th Either + * @param ts5 the 5th Either + * @param the common left-hand type of all Eithers + * @param the component type of the 1st Either + * @param the component type of the 2nd Either + * @param the component type of the 3rd Either + * @param the component type of the 4th Either + * @param the component type of the 5th Either + * @return a new {@code ForLazy5Either} builder of arity 5 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy5Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + return new ForLazy5Either<>(ts1, ts2, ts3, ts4, ts5); + } + + /** + * Creates a lazy {@code For}-comprehension over 6 Eithers. + * + *

The first argument ({@code ts1}) is the initial Either. Each subsequent + * argument ({@code ts2} .. {@code ts6}) is a function that receives all values + * bound so far and returns the next Either. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Either + * @param ts2 the 2nd Either + * @param ts3 the 3rd Either + * @param ts4 the 4th Either + * @param ts5 the 5th Either + * @param ts6 the 6th Either + * @param the common left-hand type of all Eithers + * @param the component type of the 1st Either + * @param the component type of the 2nd Either + * @param the component type of the 3rd Either + * @param the component type of the 4th Either + * @param the component type of the 5th Either + * @param the component type of the 6th Either + * @return a new {@code ForLazy6Either} builder of arity 6 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy6Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + return new ForLazy6Either<>(ts1, ts2, ts3, ts4, ts5, ts6); + } + + /** + * Creates a lazy {@code For}-comprehension over 7 Eithers. + * + *

The first argument ({@code ts1}) is the initial Either. Each subsequent + * argument ({@code ts2} .. {@code ts7}) is a function that receives all values + * bound so far and returns the next Either. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Either + * @param ts2 the 2nd Either + * @param ts3 the 3rd Either + * @param ts4 the 4th Either + * @param ts5 the 5th Either + * @param ts6 the 6th Either + * @param ts7 the 7th Either + * @param the common left-hand type of all Eithers + * @param the component type of the 1st Either + * @param the component type of the 2nd Either + * @param the component type of the 3rd Either + * @param the component type of the 4th Either + * @param the component type of the 5th Either + * @param the component type of the 6th Either + * @param the component type of the 7th Either + * @return a new {@code ForLazy7Either} builder of arity 7 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy7Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + Objects.requireNonNull(ts7, "ts7 is null"); + return new ForLazy7Either<>(ts1, ts2, ts3, ts4, ts5, ts6, ts7); + } + + /** + * Creates a lazy {@code For}-comprehension over 8 Eithers. + * + *

The first argument ({@code ts1}) is the initial Either. Each subsequent + * argument ({@code ts2} .. {@code ts8}) is a function that receives all values + * bound so far and returns the next Either. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Either + * @param ts2 the 2nd Either + * @param ts3 the 3rd Either + * @param ts4 the 4th Either + * @param ts5 the 5th Either + * @param ts6 the 6th Either + * @param ts7 the 7th Either + * @param ts8 the 8th Either + * @param the common left-hand type of all Eithers + * @param the component type of the 1st Either + * @param the component type of the 2nd Either + * @param the component type of the 3rd Either + * @param the component type of the 4th Either + * @param the component type of the 5th Either + * @param the component type of the 6th Either + * @param the component type of the 7th Either + * @param the component type of the 8th Either + * @return a new {@code ForLazy8Either} builder of arity 8 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy8Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + Objects.requireNonNull(ts7, "ts7 is null"); + Objects.requireNonNull(ts8, "ts8 is null"); + return new ForLazy8Either<>(ts1, ts2, ts3, ts4, ts5, ts6, ts7, ts8); + } + + /** + * Creates a lazy {@code For}-comprehension over two Validations. + * + *

The first argument ({@code ts1}) is the initial Validation. Each subsequent + * argument ({@code ts2} .. {@code ts2}) is a function that receives all values + * bound so far and returns the next Validation. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Validation + * @param ts2 the 2nd Validation + * @param the common left-hand type of all Validations + * @param the component type of the 1st Validation + * @param the component type of the 2nd Validation + * @return a new {@code ForLazy2Validation} builder of arity 2 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy2Validation For(Validation ts1, Function1> ts2) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + return new ForLazy2Validation<>(ts1, ts2); + } + + /** + * Creates a lazy {@code For}-comprehension over three Validations. + * + *

The first argument ({@code ts1}) is the initial Validation. Each subsequent + * argument ({@code ts2} .. {@code ts3}) is a function that receives all values + * bound so far and returns the next Validation. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Validation + * @param ts2 the 2nd Validation + * @param ts3 the 3rd Validation + * @param the common left-hand type of all Validations + * @param the component type of the 1st Validation + * @param the component type of the 2nd Validation + * @param the component type of the 3rd Validation + * @return a new {@code ForLazy3Validation} builder of arity 3 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy3Validation For(Validation ts1, Function1> ts2, Function2> ts3) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + return new ForLazy3Validation<>(ts1, ts2, ts3); + } + + /** + * Creates a lazy {@code For}-comprehension over 4 Validations. + * + *

The first argument ({@code ts1}) is the initial Validation. Each subsequent + * argument ({@code ts2} .. {@code ts4}) is a function that receives all values + * bound so far and returns the next Validation. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Validation + * @param ts2 the 2nd Validation + * @param ts3 the 3rd Validation + * @param ts4 the 4th Validation + * @param the common left-hand type of all Validations + * @param the component type of the 1st Validation + * @param the component type of the 2nd Validation + * @param the component type of the 3rd Validation + * @param the component type of the 4th Validation + * @return a new {@code ForLazy4Validation} builder of arity 4 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy4Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + return new ForLazy4Validation<>(ts1, ts2, ts3, ts4); + } + + /** + * Creates a lazy {@code For}-comprehension over 5 Validations. + * + *

The first argument ({@code ts1}) is the initial Validation. Each subsequent + * argument ({@code ts2} .. {@code ts5}) is a function that receives all values + * bound so far and returns the next Validation. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Validation + * @param ts2 the 2nd Validation + * @param ts3 the 3rd Validation + * @param ts4 the 4th Validation + * @param ts5 the 5th Validation + * @param the common left-hand type of all Validations + * @param the component type of the 1st Validation + * @param the component type of the 2nd Validation + * @param the component type of the 3rd Validation + * @param the component type of the 4th Validation + * @param the component type of the 5th Validation + * @return a new {@code ForLazy5Validation} builder of arity 5 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy5Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + return new ForLazy5Validation<>(ts1, ts2, ts3, ts4, ts5); + } + + /** + * Creates a lazy {@code For}-comprehension over 6 Validations. + * + *

The first argument ({@code ts1}) is the initial Validation. Each subsequent + * argument ({@code ts2} .. {@code ts6}) is a function that receives all values + * bound so far and returns the next Validation. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Validation + * @param ts2 the 2nd Validation + * @param ts3 the 3rd Validation + * @param ts4 the 4th Validation + * @param ts5 the 5th Validation + * @param ts6 the 6th Validation + * @param the common left-hand type of all Validations + * @param the component type of the 1st Validation + * @param the component type of the 2nd Validation + * @param the component type of the 3rd Validation + * @param the component type of the 4th Validation + * @param the component type of the 5th Validation + * @param the component type of the 6th Validation + * @return a new {@code ForLazy6Validation} builder of arity 6 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy6Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + return new ForLazy6Validation<>(ts1, ts2, ts3, ts4, ts5, ts6); + } + + /** + * Creates a lazy {@code For}-comprehension over 7 Validations. + * + *

The first argument ({@code ts1}) is the initial Validation. Each subsequent + * argument ({@code ts2} .. {@code ts7}) is a function that receives all values + * bound so far and returns the next Validation. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Validation + * @param ts2 the 2nd Validation + * @param ts3 the 3rd Validation + * @param ts4 the 4th Validation + * @param ts5 the 5th Validation + * @param ts6 the 6th Validation + * @param ts7 the 7th Validation + * @param the common left-hand type of all Validations + * @param the component type of the 1st Validation + * @param the component type of the 2nd Validation + * @param the component type of the 3rd Validation + * @param the component type of the 4th Validation + * @param the component type of the 5th Validation + * @param the component type of the 6th Validation + * @param the component type of the 7th Validation + * @return a new {@code ForLazy7Validation} builder of arity 7 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy7Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + Objects.requireNonNull(ts7, "ts7 is null"); + return new ForLazy7Validation<>(ts1, ts2, ts3, ts4, ts5, ts6, ts7); + } + + /** + * Creates a lazy {@code For}-comprehension over 8 Validations. + * + *

The first argument ({@code ts1}) is the initial Validation. Each subsequent + * argument ({@code ts2} .. {@code ts8}) is a function that receives all values + * bound so far and returns the next Validation. This only builds the lazy + * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * + * + * @param ts1 the 1st Validation + * @param ts2 the 2nd Validation + * @param ts3 the 3rd Validation + * @param ts4 the 4th Validation + * @param ts5 the 5th Validation + * @param ts6 the 6th Validation + * @param ts7 the 7th Validation + * @param ts8 the 8th Validation + * @param the common left-hand type of all Validations + * @param the component type of the 1st Validation + * @param the component type of the 2nd Validation + * @param the component type of the 3rd Validation + * @param the component type of the 4th Validation + * @param the component type of the 5th Validation + * @param the component type of the 6th Validation + * @param the component type of the 7th Validation + * @param the component type of the 8th Validation + * @return a new {@code ForLazy8Validation} builder of arity 8 + * @throws NullPointerException if any argument is {@code null} + */ + public static ForLazy8Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + Objects.requireNonNull(ts1, "ts1 is null"); + Objects.requireNonNull(ts2, "ts2 is null"); + Objects.requireNonNull(ts3, "ts3 is null"); + Objects.requireNonNull(ts4, "ts4 is null"); + Objects.requireNonNull(ts5, "ts5 is null"); + Objects.requireNonNull(ts6, "ts6 is null"); + Objects.requireNonNull(ts7, "ts7 is null"); + Objects.requireNonNull(ts8, "ts8 is null"); + return new ForLazy8Validation<>(ts1, ts2, ts3, ts4, ts5, ts6, ts7, ts8); + } + + /** + * A lazily evaluated {@code For}-comprehension with two Options. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Options are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Option + * @param the component type of the 2nd Option + */ + public static class ForLazy2Option { + + private final Option ts1; + private final Function1> ts2; + + private ForLazy2Option(Option ts1, Function1> ts2) { + this.ts1 = ts1; + this.ts2 = ts2; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Options by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Option} + * @return an {@code Option} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Option yield(BiFunction f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with three Options. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Options are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Option + * @param the component type of the 2nd Option + * @param the component type of the 3rd Option + */ + public static class ForLazy3Option { + + private final Option ts1; + private final Function1> ts2; + private final Function2> ts3; + + private ForLazy3Option(Option ts1, Function1> ts2, Function2> ts3) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Options by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Option} + * @return an {@code Option} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Option yield(Function3 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 4 Options. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Options are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Option + * @param the component type of the 2nd Option + * @param the component type of the 3rd Option + * @param the component type of the 4th Option + */ + public static class ForLazy4Option { + + private final Option ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + + private ForLazy4Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Options by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Option} + * @return an {@code Option} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Option yield(Function4 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 5 Options. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Options are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Option + * @param the component type of the 2nd Option + * @param the component type of the 3rd Option + * @param the component type of the 4th Option + * @param the component type of the 5th Option + */ + public static class ForLazy5Option { + + private final Option ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + + private ForLazy5Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Options by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Option} + * @return an {@code Option} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Option yield(Function5 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 6 Options. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Options are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Option + * @param the component type of the 2nd Option + * @param the component type of the 3rd Option + * @param the component type of the 4th Option + * @param the component type of the 5th Option + * @param the component type of the 6th Option + */ + public static class ForLazy6Option { + + private final Option ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + + private ForLazy6Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Options by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Option} + * @return an {@code Option} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Option yield(Function6 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 7 Options. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Options are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Option + * @param the component type of the 2nd Option + * @param the component type of the 3rd Option + * @param the component type of the 4th Option + * @param the component type of the 5th Option + * @param the component type of the 6th Option + * @param the component type of the 7th Option + */ + public static class ForLazy7Option { + + private final Option ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + + private ForLazy7Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + this.ts7 = ts7; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Options by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Option} + * @return an {@code Option} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Option yield(Function7 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + }); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 8 Options. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Options are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Option + * @param the component type of the 2nd Option + * @param the component type of the 3rd Option + * @param the component type of the 4th Option + * @param the component type of the 5th Option + * @param the component type of the 6th Option + * @param the component type of the 7th Option + * @param the component type of the 8th Option + */ + public static class ForLazy8Option { + + private final Option ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + private final Function7> ts8; + + private ForLazy8Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + this.ts7 = ts7; + this.ts8 = ts8; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Options by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Option} + * @return an {@code Option} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Option yield(Function8 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { + return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + }); + }); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with two Futures. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Futures are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Future + * @param the component type of the 2nd Future + */ + public static class ForLazy2Future { + + private final Future ts1; + private final Function1> ts2; + + private ForLazy2Future(Future ts1, Function1> ts2) { + this.ts1 = ts1; + this.ts2 = ts2; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Futures by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Future} + * @return an {@code Future} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Future yield(BiFunction f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with three Futures. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Futures are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Future + * @param the component type of the 2nd Future + * @param the component type of the 3rd Future + */ + public static class ForLazy3Future { + + private final Future ts1; + private final Function1> ts2; + private final Function2> ts3; + + private ForLazy3Future(Future ts1, Function1> ts2, Function2> ts3) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Futures by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Future} + * @return an {@code Future} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Future yield(Function3 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 4 Futures. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Futures are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Future + * @param the component type of the 2nd Future + * @param the component type of the 3rd Future + * @param the component type of the 4th Future + */ + public static class ForLazy4Future { + + private final Future ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + + private ForLazy4Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Futures by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Future} + * @return an {@code Future} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Future yield(Function4 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 5 Futures. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Futures are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Future + * @param the component type of the 2nd Future + * @param the component type of the 3rd Future + * @param the component type of the 4th Future + * @param the component type of the 5th Future + */ + public static class ForLazy5Future { + + private final Future ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + + private ForLazy5Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Futures by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Future} + * @return an {@code Future} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Future yield(Function5 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 6 Futures. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Futures are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Future + * @param the component type of the 2nd Future + * @param the component type of the 3rd Future + * @param the component type of the 4th Future + * @param the component type of the 5th Future + * @param the component type of the 6th Future + */ + public static class ForLazy6Future { + + private final Future ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + + private ForLazy6Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Futures by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Future} + * @return an {@code Future} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Future yield(Function6 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 7 Futures. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Futures are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Future + * @param the component type of the 2nd Future + * @param the component type of the 3rd Future + * @param the component type of the 4th Future + * @param the component type of the 5th Future + * @param the component type of the 6th Future + * @param the component type of the 7th Future + */ + public static class ForLazy7Future { + + private final Future ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + + private ForLazy7Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + this.ts7 = ts7; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Futures by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Future} + * @return an {@code Future} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Future yield(Function7 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + }); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 8 Futures. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Futures are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Future + * @param the component type of the 2nd Future + * @param the component type of the 3rd Future + * @param the component type of the 4th Future + * @param the component type of the 5th Future + * @param the component type of the 6th Future + * @param the component type of the 7th Future + * @param the component type of the 8th Future + */ + public static class ForLazy8Future { + + private final Future ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + private final Function7> ts8; + + private ForLazy8Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + this.ts7 = ts7; + this.ts8 = ts8; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Futures by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Future} + * @return an {@code Future} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Future yield(Function8 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { + return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + }); + }); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with two Trys. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Trys are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Try + * @param the component type of the 2nd Try + */ + public static class ForLazy2Try { + + private final Try ts1; + private final Function1> ts2; + + private ForLazy2Try(Try ts1, Function1> ts2) { + this.ts1 = ts1; + this.ts2 = ts2; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Trys by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Try} + * @return an {@code Try} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Try yield(BiFunction f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with three Trys. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Trys are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Try + * @param the component type of the 2nd Try + * @param the component type of the 3rd Try + */ + public static class ForLazy3Try { + + private final Try ts1; + private final Function1> ts2; + private final Function2> ts3; + + private ForLazy3Try(Try ts1, Function1> ts2, Function2> ts3) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Trys by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Try} + * @return an {@code Try} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Try yield(Function3 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 4 Trys. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Trys are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Try + * @param the component type of the 2nd Try + * @param the component type of the 3rd Try + * @param the component type of the 4th Try + */ + public static class ForLazy4Try { + + private final Try ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + + private ForLazy4Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Trys by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Try} + * @return an {@code Try} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Try yield(Function4 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 5 Trys. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Trys are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Try + * @param the component type of the 2nd Try + * @param the component type of the 3rd Try + * @param the component type of the 4th Try + * @param the component type of the 5th Try + */ + public static class ForLazy5Try { + + private final Try ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + + private ForLazy5Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Trys by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Try} + * @return an {@code Try} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Try yield(Function5 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 6 Trys. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Trys are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Try + * @param the component type of the 2nd Try + * @param the component type of the 3rd Try + * @param the component type of the 4th Try + * @param the component type of the 5th Try + * @param the component type of the 6th Try + */ + public static class ForLazy6Try { + + private final Try ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + + private ForLazy6Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Trys by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Try} + * @return an {@code Try} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Try yield(Function6 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 7 Trys. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Trys are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Try + * @param the component type of the 2nd Try + * @param the component type of the 3rd Try + * @param the component type of the 4th Try + * @param the component type of the 5th Try + * @param the component type of the 6th Try + * @param the component type of the 7th Try + */ + public static class ForLazy7Try { + + private final Try ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + + private ForLazy7Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + this.ts7 = ts7; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Trys by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Try} + * @return an {@code Try} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Try yield(Function7 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + }); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 8 Trys. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Trys are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st Try + * @param the component type of the 2nd Try + * @param the component type of the 3rd Try + * @param the component type of the 4th Try + * @param the component type of the 5th Try + * @param the component type of the 6th Try + * @param the component type of the 7th Try + * @param the component type of the 8th Try + */ + public static class ForLazy8Try { + + private final Try ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + private final Function7> ts8; + + private ForLazy8Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + this.ts7 = ts7; + this.ts8 = ts8; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Trys by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Try} + * @return an {@code Try} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Try yield(Function8 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { + return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + }); + }); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with two Lists. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Lists are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st List + * @param the component type of the 2nd List + */ + public static class ForLazy2List { + + private final List ts1; + private final Function1> ts2; + + private ForLazy2List(List ts1, Function1> ts2) { + this.ts1 = ts1; + this.ts2 = ts2; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Lists by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code List} + * @return an {@code List} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public List yield(BiFunction f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with three Lists. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Lists are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st List + * @param the component type of the 2nd List + * @param the component type of the 3rd List + */ + public static class ForLazy3List { + + private final List ts1; + private final Function1> ts2; + private final Function2> ts3; + + private ForLazy3List(List ts1, Function1> ts2, Function2> ts3) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Lists by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code List} + * @return an {@code List} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public List yield(Function3 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 4 Lists. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Lists are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st List + * @param the component type of the 2nd List + * @param the component type of the 3rd List + * @param the component type of the 4th List + */ + public static class ForLazy4List { + + private final List ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + + private ForLazy4List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Lists by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code List} + * @return an {@code List} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public List yield(Function4 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 5 Lists. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Lists are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st List + * @param the component type of the 2nd List + * @param the component type of the 3rd List + * @param the component type of the 4th List + * @param the component type of the 5th List + */ + public static class ForLazy5List { + + private final List ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + + private ForLazy5List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Lists by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code List} + * @return an {@code List} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public List yield(Function5 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 6 Lists. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Lists are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st List + * @param the component type of the 2nd List + * @param the component type of the 3rd List + * @param the component type of the 4th List + * @param the component type of the 5th List + * @param the component type of the 6th List + */ + public static class ForLazy6List { + + private final List ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + + private ForLazy6List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Lists by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code List} + * @return an {@code List} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public List yield(Function6 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 7 Lists. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Lists are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st List + * @param the component type of the 2nd List + * @param the component type of the 3rd List + * @param the component type of the 4th List + * @param the component type of the 5th List + * @param the component type of the 6th List + * @param the component type of the 7th List + */ + public static class ForLazy7List { + + private final List ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + + private ForLazy7List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + this.ts7 = ts7; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Lists by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code List} + * @return an {@code List} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public List yield(Function7 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + }); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 8 Lists. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Lists are only + * traversed when {@code yield(...)} is invoked.

+ * + + * @param the component type of the 1st List + * @param the component type of the 2nd List + * @param the component type of the 3rd List + * @param the component type of the 4th List + * @param the component type of the 5th List + * @param the component type of the 6th List + * @param the component type of the 7th List + * @param the component type of the 8th List + */ + public static class ForLazy8List { + + private final List ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + private final Function7> ts8; + + private ForLazy8List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + this.ts7 = ts7; + this.ts8 = ts8; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Lists by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code List} + * @return an {@code List} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public List yield(Function8 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { + return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + }); + }); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with two Eithers. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Eithers are only + * traversed when {@code yield(...)} is invoked.

+ * + * @param the common left-hand type of all Eithers + * @param the component type of the 1st Either + * @param the component type of the 2nd Either + */ + public static class ForLazy2Either { + + private final Either ts1; + private final Function1> ts2; + + private ForLazy2Either(Either ts1, Function1> ts2) { + this.ts1 = ts1; + this.ts2 = ts2; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Eithers by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Either} + * @return an {@code Either} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Either yield(BiFunction f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with three Eithers. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Eithers are only + * traversed when {@code yield(...)} is invoked.

+ * + * @param the common left-hand type of all Eithers + * @param the component type of the 1st Either + * @param the component type of the 2nd Either + * @param the component type of the 3rd Either + */ + public static class ForLazy3Either { + + private final Either ts1; + private final Function1> ts2; + private final Function2> ts3; + + private ForLazy3Either(Either ts1, Function1> ts2, Function2> ts3) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Eithers by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Either} + * @return an {@code Either} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Either yield(Function3 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 4 Eithers. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Eithers are only + * traversed when {@code yield(...)} is invoked.

+ * + * @param the common left-hand type of all Eithers + * @param the component type of the 1st Either + * @param the component type of the 2nd Either + * @param the component type of the 3rd Either + * @param the component type of the 4th Either + */ + public static class ForLazy4Either { + + private final Either ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + + private ForLazy4Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Eithers by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Either} + * @return an {@code Either} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Either yield(Function4 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 5 Eithers. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Eithers are only + * traversed when {@code yield(...)} is invoked.

+ * + * @param the common left-hand type of all Eithers + * @param the component type of the 1st Either + * @param the component type of the 2nd Either + * @param the component type of the 3rd Either + * @param the component type of the 4th Either + * @param the component type of the 5th Either + */ + public static class ForLazy5Either { + + private final Either ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + + private ForLazy5Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Eithers by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Either} + * @return an {@code Either} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Either yield(Function5 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 6 Eithers. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Eithers are only + * traversed when {@code yield(...)} is invoked.

+ * + * @param the common left-hand type of all Eithers + * @param the component type of the 1st Either + * @param the component type of the 2nd Either + * @param the component type of the 3rd Either + * @param the component type of the 4th Either + * @param the component type of the 5th Either + * @param the component type of the 6th Either + */ + public static class ForLazy6Either { + + private final Either ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + + private ForLazy6Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Eithers by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Either} + * @return an {@code Either} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Either yield(Function6 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 7 Eithers. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Eithers are only + * traversed when {@code yield(...)} is invoked.

+ * + * @param the common left-hand type of all Eithers + * @param the component type of the 1st Either + * @param the component type of the 2nd Either + * @param the component type of the 3rd Either + * @param the component type of the 4th Either + * @param the component type of the 5th Either + * @param the component type of the 6th Either + * @param the component type of the 7th Either + */ + public static class ForLazy7Either { + + private final Either ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + + private ForLazy7Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + this.ts7 = ts7; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Eithers by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Either} + * @return an {@code Either} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Either yield(Function7 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + }); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 8 Eithers. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Eithers are only + * traversed when {@code yield(...)} is invoked.

+ * + * @param the common left-hand type of all Eithers + * @param the component type of the 1st Either + * @param the component type of the 2nd Either + * @param the component type of the 3rd Either + * @param the component type of the 4th Either + * @param the component type of the 5th Either + * @param the component type of the 6th Either + * @param the component type of the 7th Either + * @param the component type of the 8th Either + */ + public static class ForLazy8Either { + + private final Either ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + private final Function7> ts8; + + private ForLazy8Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + this.ts7 = ts7; + this.ts8 = ts8; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Eithers by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Either} + * @return an {@code Either} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Either yield(Function8 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { + return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + }); + }); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with two Validations. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Validations are only + * traversed when {@code yield(...)} is invoked.

+ * + * @param the common left-hand type of all Validations + * @param the component type of the 1st Validation + * @param the component type of the 2nd Validation + */ + public static class ForLazy2Validation { + + private final Validation ts1; + private final Function1> ts2; + + private ForLazy2Validation(Validation ts1, Function1> ts2) { + this.ts1 = ts1; + this.ts2 = ts2; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Validations by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Validation} + * @return an {@code Validation} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Validation yield(BiFunction f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with three Validations. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Validations are only + * traversed when {@code yield(...)} is invoked.

+ * + * @param the common left-hand type of all Validations + * @param the component type of the 1st Validation + * @param the component type of the 2nd Validation + * @param the component type of the 3rd Validation + */ + public static class ForLazy3Validation { + + private final Validation ts1; + private final Function1> ts2; + private final Function2> ts3; + + private ForLazy3Validation(Validation ts1, Function1> ts2, Function2> ts3) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Validations by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Validation} + * @return an {@code Validation} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Validation yield(Function3 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 4 Validations. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Validations are only + * traversed when {@code yield(...)} is invoked.

+ * + * @param the common left-hand type of all Validations + * @param the component type of the 1st Validation + * @param the component type of the 2nd Validation + * @param the component type of the 3rd Validation + * @param the component type of the 4th Validation + */ + public static class ForLazy4Validation { + + private final Validation ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + + private ForLazy4Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Validations by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Validation} + * @return an {@code Validation} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Validation yield(Function4 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 5 Validations. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Validations are only + * traversed when {@code yield(...)} is invoked.

+ * + * @param the common left-hand type of all Validations + * @param the component type of the 1st Validation + * @param the component type of the 2nd Validation + * @param the component type of the 3rd Validation + * @param the component type of the 4th Validation + * @param the component type of the 5th Validation + */ + public static class ForLazy5Validation { + + private final Validation ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + + private ForLazy5Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Validations by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Validation} + * @return an {@code Validation} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Validation yield(Function5 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 6 Validations. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Validations are only + * traversed when {@code yield(...)} is invoked.

+ * + * @param the common left-hand type of all Validations + * @param the component type of the 1st Validation + * @param the component type of the 2nd Validation + * @param the component type of the 3rd Validation + * @param the component type of the 4th Validation + * @param the component type of the 5th Validation + * @param the component type of the 6th Validation + */ + public static class ForLazy6Validation { + + private final Validation ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + + private ForLazy6Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Validations by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Validation} + * @return an {@code Validation} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Validation yield(Function6 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 7 Validations. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Validations are only + * traversed when {@code yield(...)} is invoked.

+ * + * @param the common left-hand type of all Validations + * @param the component type of the 1st Validation + * @param the component type of the 2nd Validation + * @param the component type of the 3rd Validation + * @param the component type of the 4th Validation + * @param the component type of the 5th Validation + * @param the component type of the 6th Validation + * @param the component type of the 7th Validation + */ + public static class ForLazy7Validation { + + private final Validation ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + + private ForLazy7Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + this.ts7 = ts7; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Validations by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Validation} + * @return an {@code Validation} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Validation yield(Function7 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + }); + }); + }); + }); + }); + }); + } + } + + /** + * A lazily evaluated {@code For}-comprehension with 8 Validations. + * + *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. + * Construction is side-effect free; underlying Validations are only + * traversed when {@code yield(...)} is invoked.

+ * + * @param the common left-hand type of all Validations + * @param the component type of the 1st Validation + * @param the component type of the 2nd Validation + * @param the component type of the 3rd Validation + * @param the component type of the 4th Validation + * @param the component type of the 5th Validation + * @param the component type of the 6th Validation + * @param the component type of the 7th Validation + * @param the component type of the 8th Validation + */ + public static class ForLazy8Validation { + + private final Validation ts1; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + private final Function7> ts8; + + private ForLazy8Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + this.ts1 = ts1; + this.ts2 = ts2; + this.ts3 = ts3; + this.ts4 = ts4; + this.ts5 = ts5; + this.ts6 = ts6; + this.ts7 = ts7; + this.ts8 = ts8; + } + + /** + * Produces results by mapping the Cartesian product of all bound values. + * + *

Evaluation is lazy and delegated to the underlying Validations by + * composing flatMap/map chains.

+ * + * @param f a function that maps a tuple of bound values to a result + * @param the element type of the resulting {@code Validation} + * @return an {@code Validation} containing mapped results + * @throws NullPointerException if {@code f} is {@code null} + */ + public Validation yield(Function8 f) { + Objects.requireNonNull(f, "f is null"); + return ts1.flatMap(t1 -> { + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { + return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + }); + }); + }); + }); + }); + }); + }); + } + } + // // Structural Pattern Matching // From ab3abdec6504626719433083a6519e6007611246 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Tue, 4 Nov 2025 22:21:26 +0100 Subject: [PATCH 2/8] type variance --- vavr/generator/Generator.scala | 6 +- vavr/src-gen/main/java/io/vavr/API.java | 528 ++++++++++++------------ 2 files changed, 267 insertions(+), 267 deletions(-) diff --git a/vavr/generator/Generator.scala b/vavr/generator/Generator.scala index 8fb823d49a..3ac6981820 100644 --- a/vavr/generator/Generator.scala +++ b/vavr/generator/Generator.scala @@ -758,7 +758,7 @@ def generateMainClasses(): Unit = { if (j == 1) s"$mtype<${parameterInset}T1> ts1" else { - val inputTypes = (1 until j).gen(k => s"T$k")(", ") + val inputTypes = (1 until j).gen(k => s"? super T$k")(", ") s"Function${j - 1}<$inputTypes, $mtype<${parameterInset}T$j>> ts$j" } }(", ") @@ -806,7 +806,7 @@ def generateMainClasses(): Unit = { if (j == 1) s"private final $mtype<${parameterInset}T1> ts1;" else { - val inputTypes = (1 until j).gen(k => s"T$k")(", ") + val inputTypes = (1 until j).gen(k => s"? super T$k")(", ") s"private final Function${j - 1}<$inputTypes, $mtype<${parameterInset}T$j>> ts$j;" } }("\n") @@ -815,7 +815,7 @@ def generateMainClasses(): Unit = { if (j == 1) s"$mtype<${parameterInset}T1> ts1" else { - val inputTypes = (1 until j).gen(k => s"T$k")(", ") + val inputTypes = (1 until j).gen(k => s"? super T$k")(", ") s"Function${j - 1}<$inputTypes, $mtype<${parameterInset}T$j>> ts$j" } }(", ") diff --git a/vavr/src-gen/main/java/io/vavr/API.java b/vavr/src-gen/main/java/io/vavr/API.java index 94fd4f1642..50ee6d9a7e 100644 --- a/vavr/src-gen/main/java/io/vavr/API.java +++ b/vavr/src-gen/main/java/io/vavr/API.java @@ -5757,7 +5757,7 @@ public Validation yield(Function8 ForLazy2Option For(Option ts1, Function1> ts2) { + public static ForLazy2Option For(Option ts1, Function1> ts2) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); return new ForLazy2Option<>(ts1, ts2); @@ -5782,7 +5782,7 @@ public static ForLazy2Option For(Option ts1, Function1 ForLazy3Option For(Option ts1, Function1> ts2, Function2> ts3) { + public static ForLazy3Option For(Option ts1, Function1> ts2, Function2> ts3) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -5810,7 +5810,7 @@ public static ForLazy3Option For(Option ts1, Functi * @return a new {@code ForLazy4Option} builder of arity 4 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy4Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + public static ForLazy4Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -5841,7 +5841,7 @@ public static ForLazy4Option For(Option ts1 * @return a new {@code ForLazy5Option} builder of arity 5 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy5Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + public static ForLazy5Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -5875,7 +5875,7 @@ public static ForLazy5Option For(Option * @return a new {@code ForLazy6Option} builder of arity 6 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy6Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + public static ForLazy6Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -5912,7 +5912,7 @@ public static ForLazy6Option Fo * @return a new {@code ForLazy7Option} builder of arity 7 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy7Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + public static ForLazy7Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -5952,7 +5952,7 @@ public static ForLazy7Option ForLazy8Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + public static ForLazy8Option For(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -5981,7 +5981,7 @@ public static ForLazy8Option ForLazy2Future For(Future ts1, Function1> ts2) { + public static ForLazy2Future For(Future ts1, Function1> ts2) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); return new ForLazy2Future<>(ts1, ts2); @@ -6006,7 +6006,7 @@ public static ForLazy2Future For(Future ts1, Function1 ForLazy3Future For(Future ts1, Function1> ts2, Function2> ts3) { + public static ForLazy3Future For(Future ts1, Function1> ts2, Function2> ts3) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6034,7 +6034,7 @@ public static ForLazy3Future For(Future ts1, Functi * @return a new {@code ForLazy4Future} builder of arity 4 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy4Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + public static ForLazy4Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6065,7 +6065,7 @@ public static ForLazy4Future For(Future ts1 * @return a new {@code ForLazy5Future} builder of arity 5 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy5Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + public static ForLazy5Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6099,7 +6099,7 @@ public static ForLazy5Future For(Future * @return a new {@code ForLazy6Future} builder of arity 6 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy6Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + public static ForLazy6Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6136,7 +6136,7 @@ public static ForLazy6Future Fo * @return a new {@code ForLazy7Future} builder of arity 7 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy7Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + public static ForLazy7Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6176,7 +6176,7 @@ public static ForLazy7Future ForLazy8Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + public static ForLazy8Future For(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6205,7 +6205,7 @@ public static ForLazy8Future ForLazy2Try For(Try ts1, Function1> ts2) { + public static ForLazy2Try For(Try ts1, Function1> ts2) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); return new ForLazy2Try<>(ts1, ts2); @@ -6230,7 +6230,7 @@ public static ForLazy2Try For(Try ts1, Function1 ForLazy3Try For(Try ts1, Function1> ts2, Function2> ts3) { + public static ForLazy3Try For(Try ts1, Function1> ts2, Function2> ts3) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6258,7 +6258,7 @@ public static ForLazy3Try For(Try ts1, Function1 ForLazy4Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + public static ForLazy4Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6289,7 +6289,7 @@ public static ForLazy4Try For(Try ts1, Func * @return a new {@code ForLazy5Try} builder of arity 5 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy5Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + public static ForLazy5Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6323,7 +6323,7 @@ public static ForLazy5Try For(Try t * @return a new {@code ForLazy6Try} builder of arity 6 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy6Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + public static ForLazy6Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6360,7 +6360,7 @@ public static ForLazy6Try For(T * @return a new {@code ForLazy7Try} builder of arity 7 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy7Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + public static ForLazy7Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6400,7 +6400,7 @@ public static ForLazy7Try ForLazy8Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + public static ForLazy8Try For(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6429,7 +6429,7 @@ public static ForLazy8Try ForLazy2List For(List ts1, Function1> ts2) { + public static ForLazy2List For(List ts1, Function1> ts2) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); return new ForLazy2List<>(ts1, ts2); @@ -6454,7 +6454,7 @@ public static ForLazy2List For(List ts1, Function1 ForLazy3List For(List ts1, Function1> ts2, Function2> ts3) { + public static ForLazy3List For(List ts1, Function1> ts2, Function2> ts3) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6482,7 +6482,7 @@ public static ForLazy3List For(List ts1, Function1< * @return a new {@code ForLazy4List} builder of arity 4 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy4List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + public static ForLazy4List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6513,7 +6513,7 @@ public static ForLazy4List For(List ts1, Fu * @return a new {@code ForLazy5List} builder of arity 5 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy5List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + public static ForLazy5List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6547,7 +6547,7 @@ public static ForLazy5List For(List * @return a new {@code ForLazy6List} builder of arity 6 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy6List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + public static ForLazy6List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6584,7 +6584,7 @@ public static ForLazy6List For( * @return a new {@code ForLazy7List} builder of arity 7 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy7List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + public static ForLazy7List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6624,7 +6624,7 @@ public static ForLazy7List ForLazy8List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + public static ForLazy8List For(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6653,7 +6653,7 @@ public static ForLazy8List ForLazy2Either For(Either ts1, Function1> ts2) { + public static ForLazy2Either For(Either ts1, Function1> ts2) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); return new ForLazy2Either<>(ts1, ts2); @@ -6678,7 +6678,7 @@ public static ForLazy2Either For(Either ts1, Funct * @return a new {@code ForLazy3Either} builder of arity 3 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy3Either For(Either ts1, Function1> ts2, Function2> ts3) { + public static ForLazy3Either For(Either ts1, Function1> ts2, Function2> ts3) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6706,7 +6706,7 @@ public static ForLazy3Either For(Either ts * @return a new {@code ForLazy4Either} builder of arity 4 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy4Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + public static ForLazy4Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6737,7 +6737,7 @@ public static ForLazy4Either For(Either ForLazy5Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + public static ForLazy5Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6771,7 +6771,7 @@ public static ForLazy5Either For( * @return a new {@code ForLazy6Either} builder of arity 6 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy6Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + public static ForLazy6Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6808,7 +6808,7 @@ public static ForLazy6Either ForLazy7Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + public static ForLazy7Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6848,7 +6848,7 @@ public static ForLazy7Either ForLazy8Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + public static ForLazy8Either For(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6877,7 +6877,7 @@ public static ForLazy8Either ForLazy2Validation For(Validation ts1, Function1> ts2) { + public static ForLazy2Validation For(Validation ts1, Function1> ts2) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); return new ForLazy2Validation<>(ts1, ts2); @@ -6902,7 +6902,7 @@ public static ForLazy2Validation For(Validation ts * @return a new {@code ForLazy3Validation} builder of arity 3 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy3Validation For(Validation ts1, Function1> ts2, Function2> ts3) { + public static ForLazy3Validation For(Validation ts1, Function1> ts2, Function2> ts3) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6930,7 +6930,7 @@ public static ForLazy3Validation For(Validation ForLazy4Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + public static ForLazy4Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6961,7 +6961,7 @@ public static ForLazy4Validation For(Vali * @return a new {@code ForLazy5Validation} builder of arity 5 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy5Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + public static ForLazy5Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -6995,7 +6995,7 @@ public static ForLazy5Validation * @return a new {@code ForLazy6Validation} builder of arity 6 * @throws NullPointerException if any argument is {@code null} */ - public static ForLazy6Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + public static ForLazy6Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -7032,7 +7032,7 @@ public static ForLazy6Validation ForLazy7Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + public static ForLazy7Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -7072,7 +7072,7 @@ public static ForLazy7Validation ForLazy8Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + public static ForLazy8Validation For(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { Objects.requireNonNull(ts1, "ts1 is null"); Objects.requireNonNull(ts2, "ts2 is null"); Objects.requireNonNull(ts3, "ts3 is null"); @@ -7098,9 +7098,9 @@ public static ForLazy8Validation { private final Option ts1; - private final Function1> ts2; + private final Function1> ts2; - private ForLazy2Option(Option ts1, Function1> ts2) { + private ForLazy2Option(Option ts1, Function1> ts2) { this.ts1 = ts1; this.ts2 = ts2; } @@ -7139,10 +7139,10 @@ public Option yield(BiFunction f) { public static class ForLazy3Option { private final Option ts1; - private final Function1> ts2; - private final Function2> ts3; + private final Function1> ts2; + private final Function2> ts3; - private ForLazy3Option(Option ts1, Function1> ts2, Function2> ts3) { + private ForLazy3Option(Option ts1, Function1> ts2, Function2> ts3) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -7185,11 +7185,11 @@ public Option yield(Function3 { private final Option ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; - private ForLazy4Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + private ForLazy4Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -7236,12 +7236,12 @@ public Option yield(Function4 { private final Option ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; - private ForLazy5Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + private ForLazy5Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -7292,13 +7292,13 @@ public Option yield(Function5 { private final Option ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; - private ForLazy6Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + private ForLazy6Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -7353,14 +7353,14 @@ public Option yield(Function6 { private final Option ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; - private final Function6> ts7; - - private ForLazy7Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + + private ForLazy7Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -7419,15 +7419,15 @@ public Option yield(Function7 { private final Option ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; - private final Function6> ts7; - private final Function7> ts8; - - private ForLazy8Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + private final Function7> ts8; + + private ForLazy8Option(Option ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -7483,9 +7483,9 @@ public Option yield(Function8 { private final Future ts1; - private final Function1> ts2; + private final Function1> ts2; - private ForLazy2Future(Future ts1, Function1> ts2) { + private ForLazy2Future(Future ts1, Function1> ts2) { this.ts1 = ts1; this.ts2 = ts2; } @@ -7524,10 +7524,10 @@ public Future yield(BiFunction f) { public static class ForLazy3Future { private final Future ts1; - private final Function1> ts2; - private final Function2> ts3; + private final Function1> ts2; + private final Function2> ts3; - private ForLazy3Future(Future ts1, Function1> ts2, Function2> ts3) { + private ForLazy3Future(Future ts1, Function1> ts2, Function2> ts3) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -7570,11 +7570,11 @@ public Future yield(Function3 { private final Future ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; - private ForLazy4Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + private ForLazy4Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -7621,12 +7621,12 @@ public Future yield(Function4 { private final Future ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; - private ForLazy5Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + private ForLazy5Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -7677,13 +7677,13 @@ public Future yield(Function5 { private final Future ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; - private ForLazy6Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + private ForLazy6Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -7738,14 +7738,14 @@ public Future yield(Function6 { private final Future ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; - private final Function6> ts7; - - private ForLazy7Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + + private ForLazy7Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -7804,15 +7804,15 @@ public Future yield(Function7 { private final Future ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; - private final Function6> ts7; - private final Function7> ts8; - - private ForLazy8Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + private final Function7> ts8; + + private ForLazy8Future(Future ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -7868,9 +7868,9 @@ public Future yield(Function8 { private final Try ts1; - private final Function1> ts2; + private final Function1> ts2; - private ForLazy2Try(Try ts1, Function1> ts2) { + private ForLazy2Try(Try ts1, Function1> ts2) { this.ts1 = ts1; this.ts2 = ts2; } @@ -7909,10 +7909,10 @@ public Try yield(BiFunction f) { public static class ForLazy3Try { private final Try ts1; - private final Function1> ts2; - private final Function2> ts3; + private final Function1> ts2; + private final Function2> ts3; - private ForLazy3Try(Try ts1, Function1> ts2, Function2> ts3) { + private ForLazy3Try(Try ts1, Function1> ts2, Function2> ts3) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -7955,11 +7955,11 @@ public Try yield(Function3 { private final Try ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; - private ForLazy4Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + private ForLazy4Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8006,12 +8006,12 @@ public Try yield(Function4 { private final Try ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; - private ForLazy5Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + private ForLazy5Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8062,13 +8062,13 @@ public Try yield(Function5 { private final Try ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; - private ForLazy6Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + private ForLazy6Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8123,14 +8123,14 @@ public Try yield(Function6 { private final Try ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; - private final Function6> ts7; - - private ForLazy7Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + + private ForLazy7Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8189,15 +8189,15 @@ public Try yield(Function7 { private final Try ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; - private final Function6> ts7; - private final Function7> ts8; - - private ForLazy8Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + private final Function7> ts8; + + private ForLazy8Try(Try ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8253,9 +8253,9 @@ public Try yield(Function8 { private final List ts1; - private final Function1> ts2; + private final Function1> ts2; - private ForLazy2List(List ts1, Function1> ts2) { + private ForLazy2List(List ts1, Function1> ts2) { this.ts1 = ts1; this.ts2 = ts2; } @@ -8294,10 +8294,10 @@ public List yield(BiFunction f) { public static class ForLazy3List { private final List ts1; - private final Function1> ts2; - private final Function2> ts3; + private final Function1> ts2; + private final Function2> ts3; - private ForLazy3List(List ts1, Function1> ts2, Function2> ts3) { + private ForLazy3List(List ts1, Function1> ts2, Function2> ts3) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8340,11 +8340,11 @@ public List yield(Function3 { private final List ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; - private ForLazy4List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + private ForLazy4List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8391,12 +8391,12 @@ public List yield(Function4 { private final List ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; - private ForLazy5List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + private ForLazy5List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8447,13 +8447,13 @@ public List yield(Function5 { private final List ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; - private ForLazy6List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + private ForLazy6List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8508,14 +8508,14 @@ public List yield(Function6 { private final List ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; - private final Function6> ts7; - - private ForLazy7List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + + private ForLazy7List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8574,15 +8574,15 @@ public List yield(Function7 { private final List ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; - private final Function6> ts7; - private final Function7> ts8; - - private ForLazy8List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + private final Function7> ts8; + + private ForLazy8List(List ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8638,9 +8638,9 @@ public List yield(Function8 { private final Either ts1; - private final Function1> ts2; + private final Function1> ts2; - private ForLazy2Either(Either ts1, Function1> ts2) { + private ForLazy2Either(Either ts1, Function1> ts2) { this.ts1 = ts1; this.ts2 = ts2; } @@ -8679,10 +8679,10 @@ public Either yield(BiFunction f) public static class ForLazy3Either { private final Either ts1; - private final Function1> ts2; - private final Function2> ts3; + private final Function1> ts2; + private final Function2> ts3; - private ForLazy3Either(Either ts1, Function1> ts2, Function2> ts3) { + private ForLazy3Either(Either ts1, Function1> ts2, Function2> ts3) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8725,11 +8725,11 @@ public Either yield(Function3 { private final Either ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; - private ForLazy4Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + private ForLazy4Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8776,12 +8776,12 @@ public Either yield(Function4 { private final Either ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; - private ForLazy5Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + private ForLazy5Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8832,13 +8832,13 @@ public Either yield(Function5 { private final Either ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; - private ForLazy6Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + private ForLazy6Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8893,14 +8893,14 @@ public Either yield(Function6 { private final Either ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; - private final Function6> ts7; - - private ForLazy7Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + + private ForLazy7Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -8959,15 +8959,15 @@ public Either yield(Function7 { private final Either ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; - private final Function6> ts7; - private final Function7> ts8; - - private ForLazy8Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + private final Function7> ts8; + + private ForLazy8Either(Either ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -9023,9 +9023,9 @@ public Either yield(Function8 { private final Validation ts1; - private final Function1> ts2; + private final Function1> ts2; - private ForLazy2Validation(Validation ts1, Function1> ts2) { + private ForLazy2Validation(Validation ts1, Function1> ts2) { this.ts1 = ts1; this.ts2 = ts2; } @@ -9064,10 +9064,10 @@ public Validation yield(BiFunction { private final Validation ts1; - private final Function1> ts2; - private final Function2> ts3; + private final Function1> ts2; + private final Function2> ts3; - private ForLazy3Validation(Validation ts1, Function1> ts2, Function2> ts3) { + private ForLazy3Validation(Validation ts1, Function1> ts2, Function2> ts3) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -9110,11 +9110,11 @@ public Validation yield(Function3 { private final Validation ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; - private ForLazy4Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4) { + private ForLazy4Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -9161,12 +9161,12 @@ public Validation yield(Function4 { private final Validation ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; - private ForLazy5Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { + private ForLazy5Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -9217,13 +9217,13 @@ public Validation yield(Function5 { private final Validation ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; - private ForLazy6Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { + private ForLazy6Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -9278,14 +9278,14 @@ public Validation yield(Function6 { private final Validation ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; - private final Function6> ts7; - - private ForLazy7Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + + private ForLazy7Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; @@ -9344,15 +9344,15 @@ public Validation yield(Function7 { private final Validation ts1; - private final Function1> ts2; - private final Function2> ts3; - private final Function3> ts4; - private final Function4> ts5; - private final Function5> ts6; - private final Function6> ts7; - private final Function7> ts8; - - private ForLazy8Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { + private final Function1> ts2; + private final Function2> ts3; + private final Function3> ts4; + private final Function4> ts5; + private final Function5> ts6; + private final Function6> ts7; + private final Function7> ts8; + + private ForLazy8Validation(Validation ts1, Function1> ts2, Function2> ts3, Function3> ts4, Function4> ts5, Function5> ts6, Function6> ts7, Function7> ts8) { this.ts1 = ts1; this.ts2 = ts2; this.ts3 = ts3; From 6a6baf8a4587c0afd6626ae2de33c08afc944d87 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Wed, 5 Nov 2025 12:51:30 +0100 Subject: [PATCH 3/8] preserve ? extends R in yield() to improve type inference for nested lambdas --- vavr/generator/Generator.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/vavr/generator/Generator.scala b/vavr/generator/Generator.scala index 3ac6981820..fca524e2b4 100644 --- a/vavr/generator/Generator.scala +++ b/vavr/generator/Generator.scala @@ -796,10 +796,6 @@ def generateMainClasses(): Unit = { val forClassName = s"ForLazy$i$mtype" val parameterInset = if (monadicTypesThatNeedParameter.contains(mtype)) "L, " else "" val generics = parameterInset + (1 to i).gen(j => s"T$j")(", ") - val functionType = i match { - case 2 => BiFunctionType - case _ => s"Function$i" - } val args = (1 to i).gen(j => s"? super T$j")(", ") val fields = (1 to i).gen { j => @@ -875,7 +871,12 @@ def generateMainClasses(): Unit = { * @return an {@code $rtype} containing mapped results * @throws NullPointerException if {@code f} is {@code null} */ - public $rtype<${parameterInset}R> yield($functionType<$args, ? extends R> f) { + public $rtype<${parameterInset}R> yield(${ + if (i == 2) + s"BiFunction" + else + s"Function$i<${(1 to i).map(j => s"? super T$j").mkString(", ")}, ? extends R>" + } f) { $Objects.requireNonNull(f, "f is null"); return $yieldBody; } From 532964cefe1685c4528c1d371d4f77c96089c1f2 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Wed, 5 Nov 2025 17:14:34 +0100 Subject: [PATCH 4/8] docs --- vavr/generator/Generator.scala | 14 +- vavr/src-gen/main/java/io/vavr/API.java | 546 +++++++++++++----------- 2 files changed, 301 insertions(+), 259 deletions(-) diff --git a/vavr/generator/Generator.scala b/vavr/generator/Generator.scala index fca524e2b4..df7332d1b3 100644 --- a/vavr/generator/Generator.scala +++ b/vavr/generator/Generator.scala @@ -771,8 +771,9 @@ def generateMainClasses(): Unit = { * *

The first argument ({@code ts1}) is the initial ${mtype}. Each subsequent * argument ({@code ts2} .. {@code ts$i}) is a function that receives all values - * bound so far and returns the next ${mtype}. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next ${mtype}. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* ${(0 to i).gen(j => if (j == 0) "*" else s"* @param ts$j the ${j.ordinal} ${mtype}")("\n")} ${if (isComplex) s"* @param the common left-hand type of all ${mtype}s\n" else ""} @@ -796,7 +797,6 @@ def generateMainClasses(): Unit = { val forClassName = s"ForLazy$i$mtype" val parameterInset = if (monadicTypesThatNeedParameter.contains(mtype)) "L, " else "" val generics = parameterInset + (1 to i).gen(j => s"T$j")(", ") - val args = (1 to i).gen(j => s"? super T$j")(", ") val fields = (1 to i).gen { j => if (j == 1) @@ -846,8 +846,8 @@ def generateMainClasses(): Unit = { * A lazily evaluated {@code For}-comprehension with ${i.numerus(mtype)}. * *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying ${i.plural(mtype)} are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying ${i.plural(mtype)} are traversed + * only when {@code yield(...)} is invoked.

* ${if (monadicTypesThatNeedParameter.contains(mtype)) s"* @param the common left-hand type of all ${mtype}s\n" else ""} ${(1 to i).gen(j => s"* @param the component type of the ${j.ordinal} ${mtype}")("\n")} @@ -864,9 +864,9 @@ def generateMainClasses(): Unit = { * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying ${i.plural(mtype)} by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code $rtype} * @return an {@code $rtype} containing mapped results * @throws NullPointerException if {@code f} is {@code null} diff --git a/vavr/src-gen/main/java/io/vavr/API.java b/vavr/src-gen/main/java/io/vavr/API.java index 50ee6d9a7e..4668ae4607 100644 --- a/vavr/src-gen/main/java/io/vavr/API.java +++ b/vavr/src-gen/main/java/io/vavr/API.java @@ -5745,8 +5745,9 @@ public Validation yield(Function8The first argument ({@code ts1}) is the initial Option. Each subsequent * argument ({@code ts2} .. {@code ts2}) is a function that receives all values - * bound so far and returns the next Option. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Option. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Option @@ -5768,8 +5769,9 @@ public static ForLazy2Option For(Option ts1, Function1The first argument ({@code ts1}) is the initial Option. Each subsequent * argument ({@code ts2} .. {@code ts3}) is a function that receives all values - * bound so far and returns the next Option. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Option. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Option @@ -5794,8 +5796,9 @@ public static ForLazy3Option For(Option ts1, Functi * *

The first argument ({@code ts1}) is the initial Option. Each subsequent * argument ({@code ts2} .. {@code ts4}) is a function that receives all values - * bound so far and returns the next Option. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Option. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Option @@ -5823,8 +5826,9 @@ public static ForLazy4Option For(Option ts1 * *

The first argument ({@code ts1}) is the initial Option. Each subsequent * argument ({@code ts2} .. {@code ts5}) is a function that receives all values - * bound so far and returns the next Option. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Option. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Option @@ -5855,8 +5859,9 @@ public static ForLazy5Option For(Option * *

The first argument ({@code ts1}) is the initial Option. Each subsequent * argument ({@code ts2} .. {@code ts6}) is a function that receives all values - * bound so far and returns the next Option. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Option. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Option @@ -5890,8 +5895,9 @@ public static ForLazy6Option Fo * *

The first argument ({@code ts1}) is the initial Option. Each subsequent * argument ({@code ts2} .. {@code ts7}) is a function that receives all values - * bound so far and returns the next Option. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Option. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Option @@ -5928,8 +5934,9 @@ public static ForLazy7OptionThe first argument ({@code ts1}) is the initial Option. Each subsequent * argument ({@code ts2} .. {@code ts8}) is a function that receives all values - * bound so far and returns the next Option. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Option. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Option @@ -5969,8 +5976,9 @@ public static ForLazy8OptionThe first argument ({@code ts1}) is the initial Future. Each subsequent * argument ({@code ts2} .. {@code ts2}) is a function that receives all values - * bound so far and returns the next Future. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Future. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Future @@ -5992,8 +6000,9 @@ public static ForLazy2Future For(Future ts1, Function1The first argument ({@code ts1}) is the initial Future. Each subsequent * argument ({@code ts2} .. {@code ts3}) is a function that receives all values - * bound so far and returns the next Future. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Future. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Future @@ -6018,8 +6027,9 @@ public static ForLazy3Future For(Future ts1, Functi * *

The first argument ({@code ts1}) is the initial Future. Each subsequent * argument ({@code ts2} .. {@code ts4}) is a function that receives all values - * bound so far and returns the next Future. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Future. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Future @@ -6047,8 +6057,9 @@ public static ForLazy4Future For(Future ts1 * *

The first argument ({@code ts1}) is the initial Future. Each subsequent * argument ({@code ts2} .. {@code ts5}) is a function that receives all values - * bound so far and returns the next Future. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Future. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Future @@ -6079,8 +6090,9 @@ public static ForLazy5Future For(Future * *

The first argument ({@code ts1}) is the initial Future. Each subsequent * argument ({@code ts2} .. {@code ts6}) is a function that receives all values - * bound so far and returns the next Future. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Future. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Future @@ -6114,8 +6126,9 @@ public static ForLazy6Future Fo * *

The first argument ({@code ts1}) is the initial Future. Each subsequent * argument ({@code ts2} .. {@code ts7}) is a function that receives all values - * bound so far and returns the next Future. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Future. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Future @@ -6152,8 +6165,9 @@ public static ForLazy7FutureThe first argument ({@code ts1}) is the initial Future. Each subsequent * argument ({@code ts2} .. {@code ts8}) is a function that receives all values - * bound so far and returns the next Future. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Future. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Future @@ -6193,8 +6207,9 @@ public static ForLazy8FutureThe first argument ({@code ts1}) is the initial Try. Each subsequent * argument ({@code ts2} .. {@code ts2}) is a function that receives all values - * bound so far and returns the next Try. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Try. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Try @@ -6216,8 +6231,9 @@ public static ForLazy2Try For(Try ts1, Function1The first argument ({@code ts1}) is the initial Try. Each subsequent * argument ({@code ts2} .. {@code ts3}) is a function that receives all values - * bound so far and returns the next Try. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Try. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Try @@ -6242,8 +6258,9 @@ public static ForLazy3Try For(Try ts1, Function1The first argument ({@code ts1}) is the initial Try. Each subsequent * argument ({@code ts2} .. {@code ts4}) is a function that receives all values - * bound so far and returns the next Try. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Try. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Try @@ -6271,8 +6288,9 @@ public static ForLazy4Try For(Try ts1, Func * *

The first argument ({@code ts1}) is the initial Try. Each subsequent * argument ({@code ts2} .. {@code ts5}) is a function that receives all values - * bound so far and returns the next Try. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Try. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Try @@ -6303,8 +6321,9 @@ public static ForLazy5Try For(Try t * *

The first argument ({@code ts1}) is the initial Try. Each subsequent * argument ({@code ts2} .. {@code ts6}) is a function that receives all values - * bound so far and returns the next Try. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Try. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Try @@ -6338,8 +6357,9 @@ public static ForLazy6Try For(T * *

The first argument ({@code ts1}) is the initial Try. Each subsequent * argument ({@code ts2} .. {@code ts7}) is a function that receives all values - * bound so far and returns the next Try. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Try. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Try @@ -6376,8 +6396,9 @@ public static ForLazy7TryThe first argument ({@code ts1}) is the initial Try. Each subsequent * argument ({@code ts2} .. {@code ts8}) is a function that receives all values - * bound so far and returns the next Try. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Try. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Try @@ -6417,8 +6438,9 @@ public static ForLazy8TryThe first argument ({@code ts1}) is the initial List. Each subsequent * argument ({@code ts2} .. {@code ts2}) is a function that receives all values - * bound so far and returns the next List. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next List. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st List @@ -6440,8 +6462,9 @@ public static ForLazy2List For(List ts1, Function1The first argument ({@code ts1}) is the initial List. Each subsequent * argument ({@code ts2} .. {@code ts3}) is a function that receives all values - * bound so far and returns the next List. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next List. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st List @@ -6466,8 +6489,9 @@ public static ForLazy3List For(List ts1, Function1< * *

The first argument ({@code ts1}) is the initial List. Each subsequent * argument ({@code ts2} .. {@code ts4}) is a function that receives all values - * bound so far and returns the next List. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next List. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st List @@ -6495,8 +6519,9 @@ public static ForLazy4List For(List ts1, Fu * *

The first argument ({@code ts1}) is the initial List. Each subsequent * argument ({@code ts2} .. {@code ts5}) is a function that receives all values - * bound so far and returns the next List. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next List. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st List @@ -6527,8 +6552,9 @@ public static ForLazy5List For(List * *

The first argument ({@code ts1}) is the initial List. Each subsequent * argument ({@code ts2} .. {@code ts6}) is a function that receives all values - * bound so far and returns the next List. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next List. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st List @@ -6562,8 +6588,9 @@ public static ForLazy6List For( * *

The first argument ({@code ts1}) is the initial List. Each subsequent * argument ({@code ts2} .. {@code ts7}) is a function that receives all values - * bound so far and returns the next List. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next List. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st List @@ -6600,8 +6627,9 @@ public static ForLazy7ListThe first argument ({@code ts1}) is the initial List. Each subsequent * argument ({@code ts2} .. {@code ts8}) is a function that receives all values - * bound so far and returns the next List. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next List. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st List @@ -6641,8 +6669,9 @@ public static ForLazy8ListThe first argument ({@code ts1}) is the initial Either. Each subsequent * argument ({@code ts2} .. {@code ts2}) is a function that receives all values - * bound so far and returns the next Either. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Either. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Either @@ -6664,8 +6693,9 @@ public static ForLazy2Either For(Either ts1, Funct * *

The first argument ({@code ts1}) is the initial Either. Each subsequent * argument ({@code ts2} .. {@code ts3}) is a function that receives all values - * bound so far and returns the next Either. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Either. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Either @@ -6690,8 +6720,9 @@ public static ForLazy3Either For(Either ts * *

The first argument ({@code ts1}) is the initial Either. Each subsequent * argument ({@code ts2} .. {@code ts4}) is a function that receives all values - * bound so far and returns the next Either. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Either. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Either @@ -6719,8 +6750,9 @@ public static ForLazy4Either For(EitherThe first argument ({@code ts1}) is the initial Either. Each subsequent * argument ({@code ts2} .. {@code ts5}) is a function that receives all values - * bound so far and returns the next Either. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Either. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Either @@ -6751,8 +6783,9 @@ public static ForLazy5Either For( * *

The first argument ({@code ts1}) is the initial Either. Each subsequent * argument ({@code ts2} .. {@code ts6}) is a function that receives all values - * bound so far and returns the next Either. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Either. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Either @@ -6786,8 +6819,9 @@ public static ForLazy6EitherThe first argument ({@code ts1}) is the initial Either. Each subsequent * argument ({@code ts2} .. {@code ts7}) is a function that receives all values - * bound so far and returns the next Either. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Either. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Either @@ -6824,8 +6858,9 @@ public static ForLazy7EitherThe first argument ({@code ts1}) is the initial Either. Each subsequent * argument ({@code ts2} .. {@code ts8}) is a function that receives all values - * bound so far and returns the next Either. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Either. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Either @@ -6865,8 +6900,9 @@ public static ForLazy8EitherThe first argument ({@code ts1}) is the initial Validation. Each subsequent * argument ({@code ts2} .. {@code ts2}) is a function that receives all values - * bound so far and returns the next Validation. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Validation. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Validation @@ -6888,8 +6924,9 @@ public static ForLazy2Validation For(Validation ts * *

The first argument ({@code ts1}) is the initial Validation. Each subsequent * argument ({@code ts2} .. {@code ts3}) is a function that receives all values - * bound so far and returns the next Validation. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Validation. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Validation @@ -6914,8 +6951,9 @@ public static ForLazy3Validation For(ValidationThe first argument ({@code ts1}) is the initial Validation. Each subsequent * argument ({@code ts2} .. {@code ts4}) is a function that receives all values - * bound so far and returns the next Validation. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Validation. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Validation @@ -6943,8 +6981,9 @@ public static ForLazy4Validation For(Vali * *

The first argument ({@code ts1}) is the initial Validation. Each subsequent * argument ({@code ts2} .. {@code ts5}) is a function that receives all values - * bound so far and returns the next Validation. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Validation. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Validation @@ -6975,8 +7014,9 @@ public static ForLazy5Validation * *

The first argument ({@code ts1}) is the initial Validation. Each subsequent * argument ({@code ts2} .. {@code ts6}) is a function that receives all values - * bound so far and returns the next Validation. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Validation. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Validation @@ -7010,8 +7050,9 @@ public static ForLazy6ValidationThe first argument ({@code ts1}) is the initial Validation. Each subsequent * argument ({@code ts2} .. {@code ts7}) is a function that receives all values - * bound so far and returns the next Validation. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Validation. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Validation @@ -7048,8 +7089,9 @@ public static ForLazy7ValidationThe first argument ({@code ts1}) is the initial Validation. Each subsequent * argument ({@code ts2} .. {@code ts8}) is a function that receives all values - * bound so far and returns the next Validation. This only builds the lazy - * comprehension; effects are evaluated when {@code yield(...)} is called.

+ * bound so far and returns the next Validation. This method only constructs the + * lazy comprehension; underlying effects are evaluated when {@code yield(...)} + * is invoked.

* * * @param ts1 the 1st Validation @@ -7088,8 +7130,8 @@ public static ForLazy8ValidationConstructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Options are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Options are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Option @@ -7109,9 +7151,9 @@ private ForLazy2Option(Option ts1, Function1> ts2) { * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Options by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Option} * @return an {@code Option} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7128,8 +7170,8 @@ public Option yield(BiFunction f) { * A lazily evaluated {@code For}-comprehension with three Options. * *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Options are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Options are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Option @@ -7152,9 +7194,9 @@ private ForLazy3Option(Option ts1, Function1> ts2, Fu * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Options by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Option} * @return an {@code Option} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7173,8 +7215,8 @@ public Option yield(Function3Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Options are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Options are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Option @@ -7200,9 +7242,9 @@ private ForLazy4Option(Option ts1, Function1> ts2, Fu * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Options by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Option} * @return an {@code Option} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7223,8 +7265,8 @@ public Option yield(Function4Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Options are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Options are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Option @@ -7253,9 +7295,9 @@ private ForLazy5Option(Option ts1, Function1> ts2, Fu * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Options by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Option} * @return an {@code Option} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7278,8 +7320,8 @@ public Option yield(Function5Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Options are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Options are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Option @@ -7311,9 +7353,9 @@ private ForLazy6Option(Option ts1, Function1> ts2, Fu * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Options by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Option} * @return an {@code Option} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7338,8 +7380,8 @@ public Option yield(Function6Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Options are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Options are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Option @@ -7374,9 +7416,9 @@ private ForLazy7Option(Option ts1, Function1> ts2, Fu * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Options by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Option} * @return an {@code Option} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7403,8 +7445,8 @@ public Option yield(Function7Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Options are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Options are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Option @@ -7442,9 +7484,9 @@ private ForLazy8Option(Option ts1, Function1> ts2, Fu * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Options by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Option} * @return an {@code Option} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7473,8 +7515,8 @@ public Option yield(Function8Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Futures are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Futures are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Future @@ -7494,9 +7536,9 @@ private ForLazy2Future(Future ts1, Function1> ts2) { * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Futures by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Future} * @return an {@code Future} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7513,8 +7555,8 @@ public Future yield(BiFunction f) { * A lazily evaluated {@code For}-comprehension with three Futures. * *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Futures are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Futures are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Future @@ -7537,9 +7579,9 @@ private ForLazy3Future(Future ts1, Function1> ts2, Fu * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Futures by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Future} * @return an {@code Future} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7558,8 +7600,8 @@ public Future yield(Function3Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Futures are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Futures are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Future @@ -7585,9 +7627,9 @@ private ForLazy4Future(Future ts1, Function1> ts2, Fu * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Futures by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Future} * @return an {@code Future} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7608,8 +7650,8 @@ public Future yield(Function4Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Futures are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Futures are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Future @@ -7638,9 +7680,9 @@ private ForLazy5Future(Future ts1, Function1> ts2, Fu * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Futures by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Future} * @return an {@code Future} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7663,8 +7705,8 @@ public Future yield(Function5Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Futures are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Futures are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Future @@ -7696,9 +7738,9 @@ private ForLazy6Future(Future ts1, Function1> ts2, Fu * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Futures by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Future} * @return an {@code Future} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7723,8 +7765,8 @@ public Future yield(Function6Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Futures are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Futures are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Future @@ -7759,9 +7801,9 @@ private ForLazy7Future(Future ts1, Function1> ts2, Fu * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Futures by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Future} * @return an {@code Future} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7788,8 +7830,8 @@ public Future yield(Function7Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Futures are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Futures are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Future @@ -7827,9 +7869,9 @@ private ForLazy8Future(Future ts1, Function1> ts2, Fu * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Futures by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Future} * @return an {@code Future} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7858,8 +7900,8 @@ public Future yield(Function8Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Trys are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Trys are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Try @@ -7879,9 +7921,9 @@ private ForLazy2Try(Try ts1, Function1> ts2) { * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Trys by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Try} * @return an {@code Try} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7898,8 +7940,8 @@ public Try yield(BiFunction f) { * A lazily evaluated {@code For}-comprehension with three Trys. * *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Trys are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Trys are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Try @@ -7922,9 +7964,9 @@ private ForLazy3Try(Try ts1, Function1> ts2, Function2Evaluation is lazy and delegated to the underlying Trys by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Try} * @return an {@code Try} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7943,8 +7985,8 @@ public Try yield(Function3Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Trys are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Trys are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Try @@ -7970,9 +8012,9 @@ private ForLazy4Try(Try ts1, Function1> ts2, Function2Evaluation is lazy and delegated to the underlying Trys by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Try} * @return an {@code Try} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -7993,8 +8035,8 @@ public Try yield(Function4Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Trys are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Trys are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Try @@ -8023,9 +8065,9 @@ private ForLazy5Try(Try ts1, Function1> ts2, Function2Evaluation is lazy and delegated to the underlying Trys by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Try} * @return an {@code Try} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8048,8 +8090,8 @@ public Try yield(Function5Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Trys are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Trys are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Try @@ -8081,9 +8123,9 @@ private ForLazy6Try(Try ts1, Function1> ts2, Function2Evaluation is lazy and delegated to the underlying Trys by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Try} * @return an {@code Try} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8108,8 +8150,8 @@ public Try yield(Function6Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Trys are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Trys are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Try @@ -8144,9 +8186,9 @@ private ForLazy7Try(Try ts1, Function1> ts2, Function2Evaluation is lazy and delegated to the underlying Trys by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Try} * @return an {@code Try} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8173,8 +8215,8 @@ public Try yield(Function7Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Trys are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Trys are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st Try @@ -8212,9 +8254,9 @@ private ForLazy8Try(Try ts1, Function1> ts2, Function2Evaluation is lazy and delegated to the underlying Trys by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Try} * @return an {@code Try} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8243,8 +8285,8 @@ public Try yield(Function8Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Lists are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Lists are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st List @@ -8264,9 +8306,9 @@ private ForLazy2List(List ts1, Function1> ts2) { * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Lists by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code List} * @return an {@code List} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8283,8 +8325,8 @@ public List yield(BiFunction f) { * A lazily evaluated {@code For}-comprehension with three Lists. * *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Lists are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Lists are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st List @@ -8307,9 +8349,9 @@ private ForLazy3List(List ts1, Function1> ts2, Function * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Lists by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code List} * @return an {@code List} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8328,8 +8370,8 @@ public List yield(Function3Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Lists are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Lists are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st List @@ -8355,9 +8397,9 @@ private ForLazy4List(List ts1, Function1> ts2, Function * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Lists by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code List} * @return an {@code List} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8378,8 +8420,8 @@ public List yield(Function4Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Lists are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Lists are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st List @@ -8408,9 +8450,9 @@ private ForLazy5List(List ts1, Function1> ts2, Function * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Lists by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code List} * @return an {@code List} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8433,8 +8475,8 @@ public List yield(Function5Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Lists are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Lists are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st List @@ -8466,9 +8508,9 @@ private ForLazy6List(List ts1, Function1> ts2, Function * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Lists by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code List} * @return an {@code List} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8493,8 +8535,8 @@ public List yield(Function6Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Lists are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Lists are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st List @@ -8529,9 +8571,9 @@ private ForLazy7List(List ts1, Function1> ts2, Function * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Lists by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code List} * @return an {@code List} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8558,8 +8600,8 @@ public List yield(Function7Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Lists are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Lists are traversed + * only when {@code yield(...)} is invoked.

* * @param the component type of the 1st List @@ -8597,9 +8639,9 @@ private ForLazy8List(List ts1, Function1> ts2, Function * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Lists by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code List} * @return an {@code List} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8628,8 +8670,8 @@ public List yield(Function8Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Eithers are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Eithers are traversed + * only when {@code yield(...)} is invoked.

* * @param the common left-hand type of all Eithers * @param the component type of the 1st Either @@ -8649,9 +8691,9 @@ private ForLazy2Either(Either ts1, Function1> t * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Eithers by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Either} * @return an {@code Either} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8668,8 +8710,8 @@ public Either yield(BiFunction f) * A lazily evaluated {@code For}-comprehension with three Eithers. * *

Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Eithers are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Eithers are traversed + * only when {@code yield(...)} is invoked.

* * @param the common left-hand type of all Eithers * @param the component type of the 1st Either @@ -8692,9 +8734,9 @@ private ForLazy3Either(Either ts1, Function1> t * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Eithers by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Either} * @return an {@code Either} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8713,8 +8755,8 @@ public Either yield(Function3Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Eithers are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Eithers are traversed + * only when {@code yield(...)} is invoked.

* * @param the common left-hand type of all Eithers * @param the component type of the 1st Either @@ -8740,9 +8782,9 @@ private ForLazy4Either(Either ts1, Function1> t * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Eithers by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Either} * @return an {@code Either} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8763,8 +8805,8 @@ public Either yield(Function4Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Eithers are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Eithers are traversed + * only when {@code yield(...)} is invoked.

* * @param the common left-hand type of all Eithers * @param the component type of the 1st Either @@ -8793,9 +8835,9 @@ private ForLazy5Either(Either ts1, Function1> t * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Eithers by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Either} * @return an {@code Either} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8818,8 +8860,8 @@ public Either yield(Function5Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Eithers are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Eithers are traversed + * only when {@code yield(...)} is invoked.

* * @param the common left-hand type of all Eithers * @param the component type of the 1st Either @@ -8851,9 +8893,9 @@ private ForLazy6Either(Either ts1, Function1> t * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Eithers by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Either} * @return an {@code Either} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8878,8 +8920,8 @@ public Either yield(Function6Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Eithers are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Eithers are traversed + * only when {@code yield(...)} is invoked.

* * @param the common left-hand type of all Eithers * @param the component type of the 1st Either @@ -8914,9 +8956,9 @@ private ForLazy7Either(Either ts1, Function1> t * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Eithers by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Either} * @return an {@code Either} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -8943,8 +8985,8 @@ public Either yield(Function7Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Eithers are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Eithers are traversed + * only when {@code yield(...)} is invoked.

* * @param the common left-hand type of all Eithers * @param the component type of the 1st Either @@ -8982,9 +9024,9 @@ private ForLazy8Either(Either ts1, Function1> t * Produces results by mapping the Cartesian product of all bound values. * *

Evaluation is lazy and delegated to the underlying Eithers by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Either} * @return an {@code Either} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -9013,8 +9055,8 @@ public Either yield(Function8Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Validations are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Validations are traversed + * only when {@code yield(...)} is invoked.

* * @param the common left-hand type of all Validations * @param the component type of the 1st Validation @@ -9034,9 +9076,9 @@ private ForLazy2Validation(Validation ts1, Function1Evaluation is lazy and delegated to the underlying Validations by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Validation} * @return an {@code Validation} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -9053,8 +9095,8 @@ public Validation yield(BiFunctionConstructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Validations are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Validations are traversed + * only when {@code yield(...)} is invoked.

* * @param the common left-hand type of all Validations * @param the component type of the 1st Validation @@ -9077,9 +9119,9 @@ private ForLazy3Validation(Validation ts1, Function1Evaluation is lazy and delegated to the underlying Validations by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Validation} * @return an {@code Validation} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -9098,8 +9140,8 @@ public Validation yield(Function3Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Validations are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Validations are traversed + * only when {@code yield(...)} is invoked.

* * @param the common left-hand type of all Validations * @param the component type of the 1st Validation @@ -9125,9 +9167,9 @@ private ForLazy4Validation(Validation ts1, Function1Evaluation is lazy and delegated to the underlying Validations by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Validation} * @return an {@code Validation} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -9148,8 +9190,8 @@ public Validation yield(Function4Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Validations are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Validations are traversed + * only when {@code yield(...)} is invoked.

* * @param the common left-hand type of all Validations * @param the component type of the 1st Validation @@ -9178,9 +9220,9 @@ private ForLazy5Validation(Validation ts1, Function1Evaluation is lazy and delegated to the underlying Validations by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Validation} * @return an {@code Validation} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -9203,8 +9245,8 @@ public Validation yield(Function5Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Validations are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Validations are traversed + * only when {@code yield(...)} is invoked.

* * @param the common left-hand type of all Validations * @param the component type of the 1st Validation @@ -9236,9 +9278,9 @@ private ForLazy6Validation(Validation ts1, Function1Evaluation is lazy and delegated to the underlying Validations by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Validation} * @return an {@code Validation} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -9263,8 +9305,8 @@ public Validation yield(Function6Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Validations are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Validations are traversed + * only when {@code yield(...)} is invoked.

* * @param the common left-hand type of all Validations * @param the component type of the 1st Validation @@ -9299,9 +9341,9 @@ private ForLazy7Validation(Validation ts1, Function1Evaluation is lazy and delegated to the underlying Validations by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Validation} * @return an {@code Validation} containing mapped results * @throws NullPointerException if {@code f} is {@code null} @@ -9328,8 +9370,8 @@ public Validation yield(Function7Constructed via {@code For(...)} and evaluated by calling {@code yield(...)}. - * Construction is side-effect free; underlying Validations are only - * traversed when {@code yield(...)} is invoked.

+ * Construction is side-effect free; underlying Validations are traversed + * only when {@code yield(...)} is invoked.

* * @param the common left-hand type of all Validations * @param the component type of the 1st Validation @@ -9367,9 +9409,9 @@ private ForLazy8Validation(Validation ts1, Function1Evaluation is lazy and delegated to the underlying Validations by - * composing flatMap/map chains.

+ * composing {@code flatMap} and {@code map} chains.

* - * @param f a function that maps a tuple of bound values to a result + * @param f a function mapping a tuple of bound values to a result * @param the element type of the resulting {@code Validation} * @return an {@code Validation} containing mapped results * @throws NullPointerException if {@code f} is {@code null} From 3804557fa70c66581290662d5c74975754c9f5af Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Wed, 5 Nov 2025 17:18:45 +0100 Subject: [PATCH 5/8] indent --- vavr/generator/Generator.scala | 2 +- vavr/src-gen/main/java/io/vavr/API.java | 420 ++++++++++++------------ 2 files changed, 211 insertions(+), 211 deletions(-) diff --git a/vavr/generator/Generator.scala b/vavr/generator/Generator.scala index df7332d1b3..04e8a67d58 100644 --- a/vavr/generator/Generator.scala +++ b/vavr/generator/Generator.scala @@ -821,7 +821,7 @@ def generateMainClasses(): Unit = { val yieldBody = { def nestedLambda(j: Int): String = { val base = " " - val indent = " " * j + val indent = " " * (j + 1) if (j == i) { val argsList = (1 to i).map(k => s"t$k").mkString(", ") val inputArgs = (1 until i).map(k => s"t$k").mkString(", ") diff --git a/vavr/src-gen/main/java/io/vavr/API.java b/vavr/src-gen/main/java/io/vavr/API.java index 4668ae4607..f1653a5afa 100644 --- a/vavr/src-gen/main/java/io/vavr/API.java +++ b/vavr/src-gen/main/java/io/vavr/API.java @@ -7161,8 +7161,8 @@ private ForLazy2Option(Option ts1, Function1> ts2) { public Option yield(BiFunction f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); - }); + return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); + }); } } @@ -7204,10 +7204,10 @@ private ForLazy3Option(Option ts1, Function1> ts2, Fu public Option yield(Function3 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + }); }); - }); } } @@ -7252,12 +7252,12 @@ private ForLazy4Option(Option ts1, Function1> ts2, Fu public Option yield(Function4 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + }); }); }); - }); } } @@ -7305,14 +7305,14 @@ private ForLazy5Option(Option ts1, Function1> ts2, Fu public Option yield(Function5 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + }); }); }); }); - }); } } @@ -7363,16 +7363,16 @@ private ForLazy6Option(Option ts1, Function1> ts2, Fu public Option yield(Function6 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + }); }); }); }); }); - }); } } @@ -7426,18 +7426,18 @@ private ForLazy7Option(Option ts1, Function1> ts2, Fu public Option yield(Function7 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { - return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + }); }); }); }); }); }); - }); } } @@ -7494,20 +7494,20 @@ private ForLazy8Option(Option ts1, Function1> ts2, Fu public Option yield(Function8 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { - return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { - return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { + return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + }); }); }); }); }); }); }); - }); } } @@ -7546,8 +7546,8 @@ private ForLazy2Future(Future ts1, Function1> ts2) { public Future yield(BiFunction f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); - }); + return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); + }); } } @@ -7589,10 +7589,10 @@ private ForLazy3Future(Future ts1, Function1> ts2, Fu public Future yield(Function3 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + }); }); - }); } } @@ -7637,12 +7637,12 @@ private ForLazy4Future(Future ts1, Function1> ts2, Fu public Future yield(Function4 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + }); }); }); - }); } } @@ -7690,14 +7690,14 @@ private ForLazy5Future(Future ts1, Function1> ts2, Fu public Future yield(Function5 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + }); }); }); }); - }); } } @@ -7748,16 +7748,16 @@ private ForLazy6Future(Future ts1, Function1> ts2, Fu public Future yield(Function6 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + }); }); }); }); }); - }); } } @@ -7811,18 +7811,18 @@ private ForLazy7Future(Future ts1, Function1> ts2, Fu public Future yield(Function7 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { - return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + }); }); }); }); }); }); - }); } } @@ -7879,20 +7879,20 @@ private ForLazy8Future(Future ts1, Function1> ts2, Fu public Future yield(Function8 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { - return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { - return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { + return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + }); }); }); }); }); }); }); - }); } } @@ -7931,8 +7931,8 @@ private ForLazy2Try(Try ts1, Function1> ts2) { public Try yield(BiFunction f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); - }); + return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); + }); } } @@ -7974,10 +7974,10 @@ private ForLazy3Try(Try ts1, Function1> ts2, Function2 Try yield(Function3 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + }); }); - }); } } @@ -8022,12 +8022,12 @@ private ForLazy4Try(Try ts1, Function1> ts2, Function2 Try yield(Function4 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + }); }); }); - }); } } @@ -8075,14 +8075,14 @@ private ForLazy5Try(Try ts1, Function1> ts2, Function2 Try yield(Function5 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + }); }); }); }); - }); } } @@ -8133,16 +8133,16 @@ private ForLazy6Try(Try ts1, Function1> ts2, Function2 Try yield(Function6 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + }); }); }); }); }); - }); } } @@ -8196,18 +8196,18 @@ private ForLazy7Try(Try ts1, Function1> ts2, Function2 Try yield(Function7 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { - return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + }); }); }); }); }); }); - }); } } @@ -8264,20 +8264,20 @@ private ForLazy8Try(Try ts1, Function1> ts2, Function2 Try yield(Function8 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { - return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { - return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { + return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + }); }); }); }); }); }); }); - }); } } @@ -8316,8 +8316,8 @@ private ForLazy2List(List ts1, Function1> ts2) { public List yield(BiFunction f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); - }); + return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); + }); } } @@ -8359,10 +8359,10 @@ private ForLazy3List(List ts1, Function1> ts2, Function public List yield(Function3 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + }); }); - }); } } @@ -8407,12 +8407,12 @@ private ForLazy4List(List ts1, Function1> ts2, Function public List yield(Function4 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + }); }); }); - }); } } @@ -8460,14 +8460,14 @@ private ForLazy5List(List ts1, Function1> ts2, Function public List yield(Function5 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + }); }); }); }); - }); } } @@ -8518,16 +8518,16 @@ private ForLazy6List(List ts1, Function1> ts2, Function public List yield(Function6 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + }); }); }); }); }); - }); } } @@ -8581,18 +8581,18 @@ private ForLazy7List(List ts1, Function1> ts2, Function public List yield(Function7 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { - return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + }); }); }); }); }); }); - }); } } @@ -8649,20 +8649,20 @@ private ForLazy8List(List ts1, Function1> ts2, Function public List yield(Function8 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { - return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { - return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { + return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + }); }); }); }); }); }); }); - }); } } @@ -8701,8 +8701,8 @@ private ForLazy2Either(Either ts1, Function1> t public Either yield(BiFunction f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); - }); + return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); + }); } } @@ -8744,10 +8744,10 @@ private ForLazy3Either(Either ts1, Function1> t public Either yield(Function3 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + }); }); - }); } } @@ -8792,12 +8792,12 @@ private ForLazy4Either(Either ts1, Function1> t public Either yield(Function4 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + }); }); }); - }); } } @@ -8845,14 +8845,14 @@ private ForLazy5Either(Either ts1, Function1> t public Either yield(Function5 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + }); }); }); }); - }); } } @@ -8903,16 +8903,16 @@ private ForLazy6Either(Either ts1, Function1> t public Either yield(Function6 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + }); }); }); }); }); - }); } } @@ -8966,18 +8966,18 @@ private ForLazy7Either(Either ts1, Function1> t public Either yield(Function7 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { - return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + }); }); }); }); }); }); - }); } } @@ -9034,20 +9034,20 @@ private ForLazy8Either(Either ts1, Function1> t public Either yield(Function8 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { - return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { - return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { + return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + }); }); }); }); }); }); }); - }); } } @@ -9086,8 +9086,8 @@ private ForLazy2Validation(Validation ts1, Function1 Validation yield(BiFunction f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); - }); + return ts2.apply(t1).map(t2 -> f.apply(t1, t2)); + }); } } @@ -9129,10 +9129,10 @@ private ForLazy3Validation(Validation ts1, Function1 Validation yield(Function3 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).map(t3 -> f.apply(t1, t2, t3)); + }); }); - }); } } @@ -9177,12 +9177,12 @@ private ForLazy4Validation(Validation ts1, Function1 Validation yield(Function4 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).map(t4 -> f.apply(t1, t2, t3, t4)); + }); }); }); - }); } } @@ -9230,14 +9230,14 @@ private ForLazy5Validation(Validation ts1, Function1 Validation yield(Function5 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).map(t5 -> f.apply(t1, t2, t3, t4, t5)); + }); }); }); }); - }); } } @@ -9288,16 +9288,16 @@ private ForLazy6Validation(Validation ts1, Function1 Validation yield(Function6 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).map(t6 -> f.apply(t1, t2, t3, t4, t5, t6)); + }); }); }); }); }); - }); } } @@ -9351,18 +9351,18 @@ private ForLazy7Validation(Validation ts1, Function1 Validation yield(Function7 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { - return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).map(t7 -> f.apply(t1, t2, t3, t4, t5, t6, t7)); + }); }); }); }); }); }); - }); } } @@ -9419,20 +9419,20 @@ private ForLazy8Validation(Validation ts1, Function1 Validation yield(Function8 f) { Objects.requireNonNull(f, "f is null"); return ts1.flatMap(t1 -> { - return ts2.apply(t1).flatMap(t2 -> { - return ts3.apply(t1, t2).flatMap(t3 -> { - return ts4.apply(t1, t2, t3).flatMap(t4 -> { - return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { - return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { - return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { - return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + return ts2.apply(t1).flatMap(t2 -> { + return ts3.apply(t1, t2).flatMap(t3 -> { + return ts4.apply(t1, t2, t3).flatMap(t4 -> { + return ts5.apply(t1, t2, t3, t4).flatMap(t5 -> { + return ts6.apply(t1, t2, t3, t4, t5).flatMap(t6 -> { + return ts7.apply(t1, t2, t3, t4, t5, t6).flatMap(t7 -> { + return ts8.apply(t1, t2, t3, t4, t5, t6, t7).map(t8 -> f.apply(t1, t2, t3, t4, t5, t6, t7, t8)); + }); }); }); }); }); }); }); - }); } } From 1919ccbf95ca1096d662c3ba3e7bedad872c3cb1 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Wed, 5 Nov 2025 18:35:31 +0100 Subject: [PATCH 6/8] tests --- vavr/generator/Generator.scala | 13 + vavr/src-gen/test/java/io/vavr/APITest.java | 276 ++++++++++++++++++++ 2 files changed, 289 insertions(+) diff --git a/vavr/generator/Generator.scala b/vavr/generator/Generator.scala index 04e8a67d58..d82f9579f9 100644 --- a/vavr/generator/Generator.scala +++ b/vavr/generator/Generator.scala @@ -3122,6 +3122,19 @@ def generateTestClasses(): Unit = { ).yield(${(i > 1).gen("(")}${(1 to i).gen(j => s"i$j")(", ")}${(i > 1).gen(")")} -> ${(1 to i).gen(j => s"i$j")(" + ")}); $assertThat(result.get()).isEqualTo(${(1 to i).sum}); } + + @$test + public void shouldIterateLazyFor$mtype$i() { + final $mtype<${parameterInset}Integer> result = For( + ${(1 to i).gen(j => if (j == 1) { + s"$mtype.${builderName}($j)" + } else { + val args = (1 until j).map(k => s"r$k").mkString(", ") + s"($args) -> $mtype.${builderName}($j)" + } )(",\n")} + ).yield(${(i > 1).gen("(")}${(1 to i).gen(j => s"i$j")(", ")}${(i > 1).gen(")")} -> ${(1 to i).gen(j => s"i$j")(" + ")}); + $assertThat(result.get()).isEqualTo(${(1 to i).sum}); + } """})("\n\n"))("\n\n")} ${monadicFunctionTypesFor.gen(mtype => (1 to N).gen(i => { xs""" diff --git a/vavr/src-gen/test/java/io/vavr/APITest.java b/vavr/src-gen/test/java/io/vavr/APITest.java index f9e8e13d9f..6fac60cecd 100644 --- a/vavr/src-gen/test/java/io/vavr/APITest.java +++ b/vavr/src-gen/test/java/io/vavr/APITest.java @@ -1095,6 +1095,14 @@ public void shouldIterateForOption1() { assertThat(result.get()).isEqualTo(1); } + @Test + public void shouldIterateLazyForOption1() { + final Option result = For( + Option.of(1) + ).yield(i1 -> i1); + assertThat(result.get()).isEqualTo(1); + } + @Test public void shouldIterateForOption2() { final Option result = For( @@ -1104,6 +1112,15 @@ public void shouldIterateForOption2() { assertThat(result.get()).isEqualTo(3); } + @Test + public void shouldIterateLazyForOption2() { + final Option result = For( + Option.of(1), + (r1) -> Option.of(2) + ).yield((i1, i2) -> i1 + i2); + assertThat(result.get()).isEqualTo(3); + } + @Test public void shouldIterateForOption3() { final Option result = For( @@ -1114,6 +1131,16 @@ public void shouldIterateForOption3() { assertThat(result.get()).isEqualTo(6); } + @Test + public void shouldIterateLazyForOption3() { + final Option result = For( + Option.of(1), + (r1) -> Option.of(2), + (r1, r2) -> Option.of(3) + ).yield((i1, i2, i3) -> i1 + i2 + i3); + assertThat(result.get()).isEqualTo(6); + } + @Test public void shouldIterateForOption4() { final Option result = For( @@ -1125,6 +1152,17 @@ public void shouldIterateForOption4() { assertThat(result.get()).isEqualTo(10); } + @Test + public void shouldIterateLazyForOption4() { + final Option result = For( + Option.of(1), + (r1) -> Option.of(2), + (r1, r2) -> Option.of(3), + (r1, r2, r3) -> Option.of(4) + ).yield((i1, i2, i3, i4) -> i1 + i2 + i3 + i4); + assertThat(result.get()).isEqualTo(10); + } + @Test public void shouldIterateForOption5() { final Option result = For( @@ -1137,6 +1175,18 @@ public void shouldIterateForOption5() { assertThat(result.get()).isEqualTo(15); } + @Test + public void shouldIterateLazyForOption5() { + final Option result = For( + Option.of(1), + (r1) -> Option.of(2), + (r1, r2) -> Option.of(3), + (r1, r2, r3) -> Option.of(4), + (r1, r2, r3, r4) -> Option.of(5) + ).yield((i1, i2, i3, i4, i5) -> i1 + i2 + i3 + i4 + i5); + assertThat(result.get()).isEqualTo(15); + } + @Test public void shouldIterateForOption6() { final Option result = For( @@ -1150,6 +1200,19 @@ public void shouldIterateForOption6() { assertThat(result.get()).isEqualTo(21); } + @Test + public void shouldIterateLazyForOption6() { + final Option result = For( + Option.of(1), + (r1) -> Option.of(2), + (r1, r2) -> Option.of(3), + (r1, r2, r3) -> Option.of(4), + (r1, r2, r3, r4) -> Option.of(5), + (r1, r2, r3, r4, r5) -> Option.of(6) + ).yield((i1, i2, i3, i4, i5, i6) -> i1 + i2 + i3 + i4 + i5 + i6); + assertThat(result.get()).isEqualTo(21); + } + @Test public void shouldIterateForOption7() { final Option result = For( @@ -1164,6 +1227,20 @@ public void shouldIterateForOption7() { assertThat(result.get()).isEqualTo(28); } + @Test + public void shouldIterateLazyForOption7() { + final Option result = For( + Option.of(1), + (r1) -> Option.of(2), + (r1, r2) -> Option.of(3), + (r1, r2, r3) -> Option.of(4), + (r1, r2, r3, r4) -> Option.of(5), + (r1, r2, r3, r4, r5) -> Option.of(6), + (r1, r2, r3, r4, r5, r6) -> Option.of(7) + ).yield((i1, i2, i3, i4, i5, i6, i7) -> i1 + i2 + i3 + i4 + i5 + i6 + i7); + assertThat(result.get()).isEqualTo(28); + } + @Test public void shouldIterateForOption8() { final Option result = For( @@ -1179,6 +1256,21 @@ public void shouldIterateForOption8() { assertThat(result.get()).isEqualTo(36); } + @Test + public void shouldIterateLazyForOption8() { + final Option result = For( + Option.of(1), + (r1) -> Option.of(2), + (r1, r2) -> Option.of(3), + (r1, r2, r3) -> Option.of(4), + (r1, r2, r3, r4) -> Option.of(5), + (r1, r2, r3, r4, r5) -> Option.of(6), + (r1, r2, r3, r4, r5, r6) -> Option.of(7), + (r1, r2, r3, r4, r5, r6, r7) -> Option.of(8) + ).yield((i1, i2, i3, i4, i5, i6, i7, i8) -> i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8); + assertThat(result.get()).isEqualTo(36); + } + @Test public void shouldIterateForEither1() { final Either result = For( @@ -1187,6 +1279,14 @@ public void shouldIterateForEither1() { assertThat(result.get()).isEqualTo(1); } + @Test + public void shouldIterateLazyForEither1() { + final Either result = For( + Either.right(1) + ).yield(i1 -> i1); + assertThat(result.get()).isEqualTo(1); + } + @Test public void shouldIterateForEither2() { final Either result = For( @@ -1196,6 +1296,15 @@ public void shouldIterateForEither2() { assertThat(result.get()).isEqualTo(3); } + @Test + public void shouldIterateLazyForEither2() { + final Either result = For( + Either.right(1), + (r1) -> Either.right(2) + ).yield((i1, i2) -> i1 + i2); + assertThat(result.get()).isEqualTo(3); + } + @Test public void shouldIterateForEither3() { final Either result = For( @@ -1206,6 +1315,16 @@ public void shouldIterateForEither3() { assertThat(result.get()).isEqualTo(6); } + @Test + public void shouldIterateLazyForEither3() { + final Either result = For( + Either.right(1), + (r1) -> Either.right(2), + (r1, r2) -> Either.right(3) + ).yield((i1, i2, i3) -> i1 + i2 + i3); + assertThat(result.get()).isEqualTo(6); + } + @Test public void shouldIterateForEither4() { final Either result = For( @@ -1217,6 +1336,17 @@ public void shouldIterateForEither4() { assertThat(result.get()).isEqualTo(10); } + @Test + public void shouldIterateLazyForEither4() { + final Either result = For( + Either.right(1), + (r1) -> Either.right(2), + (r1, r2) -> Either.right(3), + (r1, r2, r3) -> Either.right(4) + ).yield((i1, i2, i3, i4) -> i1 + i2 + i3 + i4); + assertThat(result.get()).isEqualTo(10); + } + @Test public void shouldIterateForEither5() { final Either result = For( @@ -1229,6 +1359,18 @@ public void shouldIterateForEither5() { assertThat(result.get()).isEqualTo(15); } + @Test + public void shouldIterateLazyForEither5() { + final Either result = For( + Either.right(1), + (r1) -> Either.right(2), + (r1, r2) -> Either.right(3), + (r1, r2, r3) -> Either.right(4), + (r1, r2, r3, r4) -> Either.right(5) + ).yield((i1, i2, i3, i4, i5) -> i1 + i2 + i3 + i4 + i5); + assertThat(result.get()).isEqualTo(15); + } + @Test public void shouldIterateForEither6() { final Either result = For( @@ -1242,6 +1384,19 @@ public void shouldIterateForEither6() { assertThat(result.get()).isEqualTo(21); } + @Test + public void shouldIterateLazyForEither6() { + final Either result = For( + Either.right(1), + (r1) -> Either.right(2), + (r1, r2) -> Either.right(3), + (r1, r2, r3) -> Either.right(4), + (r1, r2, r3, r4) -> Either.right(5), + (r1, r2, r3, r4, r5) -> Either.right(6) + ).yield((i1, i2, i3, i4, i5, i6) -> i1 + i2 + i3 + i4 + i5 + i6); + assertThat(result.get()).isEqualTo(21); + } + @Test public void shouldIterateForEither7() { final Either result = For( @@ -1256,6 +1411,20 @@ public void shouldIterateForEither7() { assertThat(result.get()).isEqualTo(28); } + @Test + public void shouldIterateLazyForEither7() { + final Either result = For( + Either.right(1), + (r1) -> Either.right(2), + (r1, r2) -> Either.right(3), + (r1, r2, r3) -> Either.right(4), + (r1, r2, r3, r4) -> Either.right(5), + (r1, r2, r3, r4, r5) -> Either.right(6), + (r1, r2, r3, r4, r5, r6) -> Either.right(7) + ).yield((i1, i2, i3, i4, i5, i6, i7) -> i1 + i2 + i3 + i4 + i5 + i6 + i7); + assertThat(result.get()).isEqualTo(28); + } + @Test public void shouldIterateForEither8() { final Either result = For( @@ -1271,6 +1440,21 @@ public void shouldIterateForEither8() { assertThat(result.get()).isEqualTo(36); } + @Test + public void shouldIterateLazyForEither8() { + final Either result = For( + Either.right(1), + (r1) -> Either.right(2), + (r1, r2) -> Either.right(3), + (r1, r2, r3) -> Either.right(4), + (r1, r2, r3, r4) -> Either.right(5), + (r1, r2, r3, r4, r5) -> Either.right(6), + (r1, r2, r3, r4, r5, r6) -> Either.right(7), + (r1, r2, r3, r4, r5, r6, r7) -> Either.right(8) + ).yield((i1, i2, i3, i4, i5, i6, i7, i8) -> i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8); + assertThat(result.get()).isEqualTo(36); + } + @Test public void shouldIterateForValidation1() { final Validation result = For( @@ -1279,6 +1463,14 @@ public void shouldIterateForValidation1() { assertThat(result.get()).isEqualTo(1); } + @Test + public void shouldIterateLazyForValidation1() { + final Validation result = For( + Validation.valid(1) + ).yield(i1 -> i1); + assertThat(result.get()).isEqualTo(1); + } + @Test public void shouldIterateForValidation2() { final Validation result = For( @@ -1288,6 +1480,15 @@ public void shouldIterateForValidation2() { assertThat(result.get()).isEqualTo(3); } + @Test + public void shouldIterateLazyForValidation2() { + final Validation result = For( + Validation.valid(1), + (r1) -> Validation.valid(2) + ).yield((i1, i2) -> i1 + i2); + assertThat(result.get()).isEqualTo(3); + } + @Test public void shouldIterateForValidation3() { final Validation result = For( @@ -1298,6 +1499,16 @@ public void shouldIterateForValidation3() { assertThat(result.get()).isEqualTo(6); } + @Test + public void shouldIterateLazyForValidation3() { + final Validation result = For( + Validation.valid(1), + (r1) -> Validation.valid(2), + (r1, r2) -> Validation.valid(3) + ).yield((i1, i2, i3) -> i1 + i2 + i3); + assertThat(result.get()).isEqualTo(6); + } + @Test public void shouldIterateForValidation4() { final Validation result = For( @@ -1309,6 +1520,17 @@ public void shouldIterateForValidation4() { assertThat(result.get()).isEqualTo(10); } + @Test + public void shouldIterateLazyForValidation4() { + final Validation result = For( + Validation.valid(1), + (r1) -> Validation.valid(2), + (r1, r2) -> Validation.valid(3), + (r1, r2, r3) -> Validation.valid(4) + ).yield((i1, i2, i3, i4) -> i1 + i2 + i3 + i4); + assertThat(result.get()).isEqualTo(10); + } + @Test public void shouldIterateForValidation5() { final Validation result = For( @@ -1321,6 +1543,18 @@ public void shouldIterateForValidation5() { assertThat(result.get()).isEqualTo(15); } + @Test + public void shouldIterateLazyForValidation5() { + final Validation result = For( + Validation.valid(1), + (r1) -> Validation.valid(2), + (r1, r2) -> Validation.valid(3), + (r1, r2, r3) -> Validation.valid(4), + (r1, r2, r3, r4) -> Validation.valid(5) + ).yield((i1, i2, i3, i4, i5) -> i1 + i2 + i3 + i4 + i5); + assertThat(result.get()).isEqualTo(15); + } + @Test public void shouldIterateForValidation6() { final Validation result = For( @@ -1334,6 +1568,19 @@ public void shouldIterateForValidation6() { assertThat(result.get()).isEqualTo(21); } + @Test + public void shouldIterateLazyForValidation6() { + final Validation result = For( + Validation.valid(1), + (r1) -> Validation.valid(2), + (r1, r2) -> Validation.valid(3), + (r1, r2, r3) -> Validation.valid(4), + (r1, r2, r3, r4) -> Validation.valid(5), + (r1, r2, r3, r4, r5) -> Validation.valid(6) + ).yield((i1, i2, i3, i4, i5, i6) -> i1 + i2 + i3 + i4 + i5 + i6); + assertThat(result.get()).isEqualTo(21); + } + @Test public void shouldIterateForValidation7() { final Validation result = For( @@ -1348,6 +1595,20 @@ public void shouldIterateForValidation7() { assertThat(result.get()).isEqualTo(28); } + @Test + public void shouldIterateLazyForValidation7() { + final Validation result = For( + Validation.valid(1), + (r1) -> Validation.valid(2), + (r1, r2) -> Validation.valid(3), + (r1, r2, r3) -> Validation.valid(4), + (r1, r2, r3, r4) -> Validation.valid(5), + (r1, r2, r3, r4, r5) -> Validation.valid(6), + (r1, r2, r3, r4, r5, r6) -> Validation.valid(7) + ).yield((i1, i2, i3, i4, i5, i6, i7) -> i1 + i2 + i3 + i4 + i5 + i6 + i7); + assertThat(result.get()).isEqualTo(28); + } + @Test public void shouldIterateForValidation8() { final Validation result = For( @@ -1363,6 +1624,21 @@ public void shouldIterateForValidation8() { assertThat(result.get()).isEqualTo(36); } + @Test + public void shouldIterateLazyForValidation8() { + final Validation result = For( + Validation.valid(1), + (r1) -> Validation.valid(2), + (r1, r2) -> Validation.valid(3), + (r1, r2, r3) -> Validation.valid(4), + (r1, r2, r3, r4) -> Validation.valid(5), + (r1, r2, r3, r4, r5) -> Validation.valid(6), + (r1, r2, r3, r4, r5, r6) -> Validation.valid(7), + (r1, r2, r3, r4, r5, r6, r7) -> Validation.valid(8) + ).yield((i1, i2, i3, i4, i5, i6, i7, i8) -> i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8); + assertThat(result.get()).isEqualTo(36); + } + @Test public void shouldIterateForFuture1() { final Future result = For( From 4fea8b507a711a5fec8beaf4e0e08e5bb78e53e2 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Wed, 5 Nov 2025 19:01:33 +0100 Subject: [PATCH 7/8] better tests --- vavr/generator/Generator.scala | 10 +- vavr/src-gen/test/java/io/vavr/APITest.java | 312 +++++++++++++------- 2 files changed, 212 insertions(+), 110 deletions(-) diff --git a/vavr/generator/Generator.scala b/vavr/generator/Generator.scala index d82f9579f9..99f6206fe1 100644 --- a/vavr/generator/Generator.scala +++ b/vavr/generator/Generator.scala @@ -3130,13 +3130,19 @@ def generateTestClasses(): Unit = { s"$mtype.${builderName}($j)" } else { val args = (1 until j).map(k => s"r$k").mkString(", ") - s"($args) -> $mtype.${builderName}($j)" + val argsUsed = (1 until j).map(k => s"r$k").mkString(" + ") + s"($args) -> $mtype.${builderName}(${argsUsed} + $j)" } )(",\n")} ).yield(${(i > 1).gen("(")}${(1 to i).gen(j => s"i$j")(", ")}${(i > 1).gen(")")} -> ${(1 to i).gen(j => s"i$j")(" + ")}); - $assertThat(result.get()).isEqualTo(${(1 to i).sum}); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << ($i + 1)) - 2 - $i); } """})("\n\n"))("\n\n")} + ${monadicFunctionTypesFor.gen(mtype => (1 to N).gen(i => { xs""" @$test public void shouldIterateFor$mtype$i() { diff --git a/vavr/src-gen/test/java/io/vavr/APITest.java b/vavr/src-gen/test/java/io/vavr/APITest.java index 6fac60cecd..e2aae86fa5 100644 --- a/vavr/src-gen/test/java/io/vavr/APITest.java +++ b/vavr/src-gen/test/java/io/vavr/APITest.java @@ -1100,7 +1100,11 @@ public void shouldIterateLazyForOption1() { final Option result = For( Option.of(1) ).yield(i1 -> i1); - assertThat(result.get()).isEqualTo(1); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (1 + 1)) - 2 - 1); } @Test @@ -1116,9 +1120,13 @@ public void shouldIterateForOption2() { public void shouldIterateLazyForOption2() { final Option result = For( Option.of(1), - (r1) -> Option.of(2) + (r1) -> Option.of(r1 + 2) ).yield((i1, i2) -> i1 + i2); - assertThat(result.get()).isEqualTo(3); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (2 + 1)) - 2 - 2); } @Test @@ -1135,10 +1143,14 @@ public void shouldIterateForOption3() { public void shouldIterateLazyForOption3() { final Option result = For( Option.of(1), - (r1) -> Option.of(2), - (r1, r2) -> Option.of(3) + (r1) -> Option.of(r1 + 2), + (r1, r2) -> Option.of(r1 + r2 + 3) ).yield((i1, i2, i3) -> i1 + i2 + i3); - assertThat(result.get()).isEqualTo(6); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (3 + 1)) - 2 - 3); } @Test @@ -1156,11 +1168,15 @@ public void shouldIterateForOption4() { public void shouldIterateLazyForOption4() { final Option result = For( Option.of(1), - (r1) -> Option.of(2), - (r1, r2) -> Option.of(3), - (r1, r2, r3) -> Option.of(4) + (r1) -> Option.of(r1 + 2), + (r1, r2) -> Option.of(r1 + r2 + 3), + (r1, r2, r3) -> Option.of(r1 + r2 + r3 + 4) ).yield((i1, i2, i3, i4) -> i1 + i2 + i3 + i4); - assertThat(result.get()).isEqualTo(10); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (4 + 1)) - 2 - 4); } @Test @@ -1179,12 +1195,16 @@ public void shouldIterateForOption5() { public void shouldIterateLazyForOption5() { final Option result = For( Option.of(1), - (r1) -> Option.of(2), - (r1, r2) -> Option.of(3), - (r1, r2, r3) -> Option.of(4), - (r1, r2, r3, r4) -> Option.of(5) + (r1) -> Option.of(r1 + 2), + (r1, r2) -> Option.of(r1 + r2 + 3), + (r1, r2, r3) -> Option.of(r1 + r2 + r3 + 4), + (r1, r2, r3, r4) -> Option.of(r1 + r2 + r3 + r4 + 5) ).yield((i1, i2, i3, i4, i5) -> i1 + i2 + i3 + i4 + i5); - assertThat(result.get()).isEqualTo(15); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (5 + 1)) - 2 - 5); } @Test @@ -1204,13 +1224,17 @@ public void shouldIterateForOption6() { public void shouldIterateLazyForOption6() { final Option result = For( Option.of(1), - (r1) -> Option.of(2), - (r1, r2) -> Option.of(3), - (r1, r2, r3) -> Option.of(4), - (r1, r2, r3, r4) -> Option.of(5), - (r1, r2, r3, r4, r5) -> Option.of(6) + (r1) -> Option.of(r1 + 2), + (r1, r2) -> Option.of(r1 + r2 + 3), + (r1, r2, r3) -> Option.of(r1 + r2 + r3 + 4), + (r1, r2, r3, r4) -> Option.of(r1 + r2 + r3 + r4 + 5), + (r1, r2, r3, r4, r5) -> Option.of(r1 + r2 + r3 + r4 + r5 + 6) ).yield((i1, i2, i3, i4, i5, i6) -> i1 + i2 + i3 + i4 + i5 + i6); - assertThat(result.get()).isEqualTo(21); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (6 + 1)) - 2 - 6); } @Test @@ -1231,14 +1255,18 @@ public void shouldIterateForOption7() { public void shouldIterateLazyForOption7() { final Option result = For( Option.of(1), - (r1) -> Option.of(2), - (r1, r2) -> Option.of(3), - (r1, r2, r3) -> Option.of(4), - (r1, r2, r3, r4) -> Option.of(5), - (r1, r2, r3, r4, r5) -> Option.of(6), - (r1, r2, r3, r4, r5, r6) -> Option.of(7) + (r1) -> Option.of(r1 + 2), + (r1, r2) -> Option.of(r1 + r2 + 3), + (r1, r2, r3) -> Option.of(r1 + r2 + r3 + 4), + (r1, r2, r3, r4) -> Option.of(r1 + r2 + r3 + r4 + 5), + (r1, r2, r3, r4, r5) -> Option.of(r1 + r2 + r3 + r4 + r5 + 6), + (r1, r2, r3, r4, r5, r6) -> Option.of(r1 + r2 + r3 + r4 + r5 + r6 + 7) ).yield((i1, i2, i3, i4, i5, i6, i7) -> i1 + i2 + i3 + i4 + i5 + i6 + i7); - assertThat(result.get()).isEqualTo(28); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (7 + 1)) - 2 - 7); } @Test @@ -1260,15 +1288,19 @@ public void shouldIterateForOption8() { public void shouldIterateLazyForOption8() { final Option result = For( Option.of(1), - (r1) -> Option.of(2), - (r1, r2) -> Option.of(3), - (r1, r2, r3) -> Option.of(4), - (r1, r2, r3, r4) -> Option.of(5), - (r1, r2, r3, r4, r5) -> Option.of(6), - (r1, r2, r3, r4, r5, r6) -> Option.of(7), - (r1, r2, r3, r4, r5, r6, r7) -> Option.of(8) + (r1) -> Option.of(r1 + 2), + (r1, r2) -> Option.of(r1 + r2 + 3), + (r1, r2, r3) -> Option.of(r1 + r2 + r3 + 4), + (r1, r2, r3, r4) -> Option.of(r1 + r2 + r3 + r4 + 5), + (r1, r2, r3, r4, r5) -> Option.of(r1 + r2 + r3 + r4 + r5 + 6), + (r1, r2, r3, r4, r5, r6) -> Option.of(r1 + r2 + r3 + r4 + r5 + r6 + 7), + (r1, r2, r3, r4, r5, r6, r7) -> Option.of(r1 + r2 + r3 + r4 + r5 + r6 + r7 + 8) ).yield((i1, i2, i3, i4, i5, i6, i7, i8) -> i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8); - assertThat(result.get()).isEqualTo(36); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (8 + 1)) - 2 - 8); } @Test @@ -1284,7 +1316,11 @@ public void shouldIterateLazyForEither1() { final Either result = For( Either.right(1) ).yield(i1 -> i1); - assertThat(result.get()).isEqualTo(1); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (1 + 1)) - 2 - 1); } @Test @@ -1300,9 +1336,13 @@ public void shouldIterateForEither2() { public void shouldIterateLazyForEither2() { final Either result = For( Either.right(1), - (r1) -> Either.right(2) + (r1) -> Either.right(r1 + 2) ).yield((i1, i2) -> i1 + i2); - assertThat(result.get()).isEqualTo(3); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (2 + 1)) - 2 - 2); } @Test @@ -1319,10 +1359,14 @@ public void shouldIterateForEither3() { public void shouldIterateLazyForEither3() { final Either result = For( Either.right(1), - (r1) -> Either.right(2), - (r1, r2) -> Either.right(3) + (r1) -> Either.right(r1 + 2), + (r1, r2) -> Either.right(r1 + r2 + 3) ).yield((i1, i2, i3) -> i1 + i2 + i3); - assertThat(result.get()).isEqualTo(6); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (3 + 1)) - 2 - 3); } @Test @@ -1340,11 +1384,15 @@ public void shouldIterateForEither4() { public void shouldIterateLazyForEither4() { final Either result = For( Either.right(1), - (r1) -> Either.right(2), - (r1, r2) -> Either.right(3), - (r1, r2, r3) -> Either.right(4) + (r1) -> Either.right(r1 + 2), + (r1, r2) -> Either.right(r1 + r2 + 3), + (r1, r2, r3) -> Either.right(r1 + r2 + r3 + 4) ).yield((i1, i2, i3, i4) -> i1 + i2 + i3 + i4); - assertThat(result.get()).isEqualTo(10); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (4 + 1)) - 2 - 4); } @Test @@ -1363,12 +1411,16 @@ public void shouldIterateForEither5() { public void shouldIterateLazyForEither5() { final Either result = For( Either.right(1), - (r1) -> Either.right(2), - (r1, r2) -> Either.right(3), - (r1, r2, r3) -> Either.right(4), - (r1, r2, r3, r4) -> Either.right(5) + (r1) -> Either.right(r1 + 2), + (r1, r2) -> Either.right(r1 + r2 + 3), + (r1, r2, r3) -> Either.right(r1 + r2 + r3 + 4), + (r1, r2, r3, r4) -> Either.right(r1 + r2 + r3 + r4 + 5) ).yield((i1, i2, i3, i4, i5) -> i1 + i2 + i3 + i4 + i5); - assertThat(result.get()).isEqualTo(15); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (5 + 1)) - 2 - 5); } @Test @@ -1388,13 +1440,17 @@ public void shouldIterateForEither6() { public void shouldIterateLazyForEither6() { final Either result = For( Either.right(1), - (r1) -> Either.right(2), - (r1, r2) -> Either.right(3), - (r1, r2, r3) -> Either.right(4), - (r1, r2, r3, r4) -> Either.right(5), - (r1, r2, r3, r4, r5) -> Either.right(6) + (r1) -> Either.right(r1 + 2), + (r1, r2) -> Either.right(r1 + r2 + 3), + (r1, r2, r3) -> Either.right(r1 + r2 + r3 + 4), + (r1, r2, r3, r4) -> Either.right(r1 + r2 + r3 + r4 + 5), + (r1, r2, r3, r4, r5) -> Either.right(r1 + r2 + r3 + r4 + r5 + 6) ).yield((i1, i2, i3, i4, i5, i6) -> i1 + i2 + i3 + i4 + i5 + i6); - assertThat(result.get()).isEqualTo(21); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (6 + 1)) - 2 - 6); } @Test @@ -1415,14 +1471,18 @@ public void shouldIterateForEither7() { public void shouldIterateLazyForEither7() { final Either result = For( Either.right(1), - (r1) -> Either.right(2), - (r1, r2) -> Either.right(3), - (r1, r2, r3) -> Either.right(4), - (r1, r2, r3, r4) -> Either.right(5), - (r1, r2, r3, r4, r5) -> Either.right(6), - (r1, r2, r3, r4, r5, r6) -> Either.right(7) + (r1) -> Either.right(r1 + 2), + (r1, r2) -> Either.right(r1 + r2 + 3), + (r1, r2, r3) -> Either.right(r1 + r2 + r3 + 4), + (r1, r2, r3, r4) -> Either.right(r1 + r2 + r3 + r4 + 5), + (r1, r2, r3, r4, r5) -> Either.right(r1 + r2 + r3 + r4 + r5 + 6), + (r1, r2, r3, r4, r5, r6) -> Either.right(r1 + r2 + r3 + r4 + r5 + r6 + 7) ).yield((i1, i2, i3, i4, i5, i6, i7) -> i1 + i2 + i3 + i4 + i5 + i6 + i7); - assertThat(result.get()).isEqualTo(28); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (7 + 1)) - 2 - 7); } @Test @@ -1444,15 +1504,19 @@ public void shouldIterateForEither8() { public void shouldIterateLazyForEither8() { final Either result = For( Either.right(1), - (r1) -> Either.right(2), - (r1, r2) -> Either.right(3), - (r1, r2, r3) -> Either.right(4), - (r1, r2, r3, r4) -> Either.right(5), - (r1, r2, r3, r4, r5) -> Either.right(6), - (r1, r2, r3, r4, r5, r6) -> Either.right(7), - (r1, r2, r3, r4, r5, r6, r7) -> Either.right(8) + (r1) -> Either.right(r1 + 2), + (r1, r2) -> Either.right(r1 + r2 + 3), + (r1, r2, r3) -> Either.right(r1 + r2 + r3 + 4), + (r1, r2, r3, r4) -> Either.right(r1 + r2 + r3 + r4 + 5), + (r1, r2, r3, r4, r5) -> Either.right(r1 + r2 + r3 + r4 + r5 + 6), + (r1, r2, r3, r4, r5, r6) -> Either.right(r1 + r2 + r3 + r4 + r5 + r6 + 7), + (r1, r2, r3, r4, r5, r6, r7) -> Either.right(r1 + r2 + r3 + r4 + r5 + r6 + r7 + 8) ).yield((i1, i2, i3, i4, i5, i6, i7, i8) -> i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8); - assertThat(result.get()).isEqualTo(36); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (8 + 1)) - 2 - 8); } @Test @@ -1468,7 +1532,11 @@ public void shouldIterateLazyForValidation1() { final Validation result = For( Validation.valid(1) ).yield(i1 -> i1); - assertThat(result.get()).isEqualTo(1); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (1 + 1)) - 2 - 1); } @Test @@ -1484,9 +1552,13 @@ public void shouldIterateForValidation2() { public void shouldIterateLazyForValidation2() { final Validation result = For( Validation.valid(1), - (r1) -> Validation.valid(2) + (r1) -> Validation.valid(r1 + 2) ).yield((i1, i2) -> i1 + i2); - assertThat(result.get()).isEqualTo(3); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (2 + 1)) - 2 - 2); } @Test @@ -1503,10 +1575,14 @@ public void shouldIterateForValidation3() { public void shouldIterateLazyForValidation3() { final Validation result = For( Validation.valid(1), - (r1) -> Validation.valid(2), - (r1, r2) -> Validation.valid(3) + (r1) -> Validation.valid(r1 + 2), + (r1, r2) -> Validation.valid(r1 + r2 + 3) ).yield((i1, i2, i3) -> i1 + i2 + i3); - assertThat(result.get()).isEqualTo(6); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (3 + 1)) - 2 - 3); } @Test @@ -1524,11 +1600,15 @@ public void shouldIterateForValidation4() { public void shouldIterateLazyForValidation4() { final Validation result = For( Validation.valid(1), - (r1) -> Validation.valid(2), - (r1, r2) -> Validation.valid(3), - (r1, r2, r3) -> Validation.valid(4) + (r1) -> Validation.valid(r1 + 2), + (r1, r2) -> Validation.valid(r1 + r2 + 3), + (r1, r2, r3) -> Validation.valid(r1 + r2 + r3 + 4) ).yield((i1, i2, i3, i4) -> i1 + i2 + i3 + i4); - assertThat(result.get()).isEqualTo(10); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (4 + 1)) - 2 - 4); } @Test @@ -1547,12 +1627,16 @@ public void shouldIterateForValidation5() { public void shouldIterateLazyForValidation5() { final Validation result = For( Validation.valid(1), - (r1) -> Validation.valid(2), - (r1, r2) -> Validation.valid(3), - (r1, r2, r3) -> Validation.valid(4), - (r1, r2, r3, r4) -> Validation.valid(5) + (r1) -> Validation.valid(r1 + 2), + (r1, r2) -> Validation.valid(r1 + r2 + 3), + (r1, r2, r3) -> Validation.valid(r1 + r2 + r3 + 4), + (r1, r2, r3, r4) -> Validation.valid(r1 + r2 + r3 + r4 + 5) ).yield((i1, i2, i3, i4, i5) -> i1 + i2 + i3 + i4 + i5); - assertThat(result.get()).isEqualTo(15); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (5 + 1)) - 2 - 5); } @Test @@ -1572,13 +1656,17 @@ public void shouldIterateForValidation6() { public void shouldIterateLazyForValidation6() { final Validation result = For( Validation.valid(1), - (r1) -> Validation.valid(2), - (r1, r2) -> Validation.valid(3), - (r1, r2, r3) -> Validation.valid(4), - (r1, r2, r3, r4) -> Validation.valid(5), - (r1, r2, r3, r4, r5) -> Validation.valid(6) + (r1) -> Validation.valid(r1 + 2), + (r1, r2) -> Validation.valid(r1 + r2 + 3), + (r1, r2, r3) -> Validation.valid(r1 + r2 + r3 + 4), + (r1, r2, r3, r4) -> Validation.valid(r1 + r2 + r3 + r4 + 5), + (r1, r2, r3, r4, r5) -> Validation.valid(r1 + r2 + r3 + r4 + r5 + 6) ).yield((i1, i2, i3, i4, i5, i6) -> i1 + i2 + i3 + i4 + i5 + i6); - assertThat(result.get()).isEqualTo(21); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (6 + 1)) - 2 - 6); } @Test @@ -1599,14 +1687,18 @@ public void shouldIterateForValidation7() { public void shouldIterateLazyForValidation7() { final Validation result = For( Validation.valid(1), - (r1) -> Validation.valid(2), - (r1, r2) -> Validation.valid(3), - (r1, r2, r3) -> Validation.valid(4), - (r1, r2, r3, r4) -> Validation.valid(5), - (r1, r2, r3, r4, r5) -> Validation.valid(6), - (r1, r2, r3, r4, r5, r6) -> Validation.valid(7) + (r1) -> Validation.valid(r1 + 2), + (r1, r2) -> Validation.valid(r1 + r2 + 3), + (r1, r2, r3) -> Validation.valid(r1 + r2 + r3 + 4), + (r1, r2, r3, r4) -> Validation.valid(r1 + r2 + r3 + r4 + 5), + (r1, r2, r3, r4, r5) -> Validation.valid(r1 + r2 + r3 + r4 + r5 + 6), + (r1, r2, r3, r4, r5, r6) -> Validation.valid(r1 + r2 + r3 + r4 + r5 + r6 + 7) ).yield((i1, i2, i3, i4, i5, i6, i7) -> i1 + i2 + i3 + i4 + i5 + i6 + i7); - assertThat(result.get()).isEqualTo(28); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (7 + 1)) - 2 - 7); } @Test @@ -1628,15 +1720,19 @@ public void shouldIterateForValidation8() { public void shouldIterateLazyForValidation8() { final Validation result = For( Validation.valid(1), - (r1) -> Validation.valid(2), - (r1, r2) -> Validation.valid(3), - (r1, r2, r3) -> Validation.valid(4), - (r1, r2, r3, r4) -> Validation.valid(5), - (r1, r2, r3, r4, r5) -> Validation.valid(6), - (r1, r2, r3, r4, r5, r6) -> Validation.valid(7), - (r1, r2, r3, r4, r5, r6, r7) -> Validation.valid(8) + (r1) -> Validation.valid(r1 + 2), + (r1, r2) -> Validation.valid(r1 + r2 + 3), + (r1, r2, r3) -> Validation.valid(r1 + r2 + r3 + 4), + (r1, r2, r3, r4) -> Validation.valid(r1 + r2 + r3 + r4 + 5), + (r1, r2, r3, r4, r5) -> Validation.valid(r1 + r2 + r3 + r4 + r5 + 6), + (r1, r2, r3, r4, r5, r6) -> Validation.valid(r1 + r2 + r3 + r4 + r5 + r6 + 7), + (r1, r2, r3, r4, r5, r6, r7) -> Validation.valid(r1 + r2 + r3 + r4 + r5 + r6 + r7 + 8) ).yield((i1, i2, i3, i4, i5, i6, i7, i8) -> i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8); - assertThat(result.get()).isEqualTo(36); + + // Each step builds on the sum of all previous results plus its index + // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ. + // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n + assertThat(result.get()).isEqualTo((1 << (8 + 1)) - 2 - 8); } @Test From 9713057d63152368c2bc2ebe3c94e5cd82bb28bc Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Thu, 6 Nov 2025 08:25:31 +0100 Subject: [PATCH 8/8] better indentation --- vavr/generator/Generator.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vavr/generator/Generator.scala b/vavr/generator/Generator.scala index 99f6206fe1..2060fdce54 100644 --- a/vavr/generator/Generator.scala +++ b/vavr/generator/Generator.scala @@ -820,7 +820,7 @@ def generateMainClasses(): Unit = { val yieldBody = { def nestedLambda(j: Int): String = { - val base = " " + val base = " " * 23 val indent = " " * (j + 1) if (j == i) { val argsList = (1 to i).map(k => s"t$k").mkString(", ")