Venkat
03/05/2025, 12:42 PMimport arrow.resilience.Schedule
suspend fun main() {
var result = ""
Schedule
.doWhile<String> { input, output -> input.length <= 5 }
.repeat {
result += "a"
result
}
println(result)
}
I have seen this example in the Arrow documentation https://arrow-kt.io/learn/resilience/retry-and-repeat/. I don't understand what the use of output
in the doWhile
. Why always both input
and output
are the same? Could someone please explain?simon.vergauwen
03/05/2025, 3:32 PMdoWhile
is derived from the method doWhile
which can have a different Input
and Output
.
You're right that in this case the second argument is a bit redundant, and could be removed at the cost of an additional lambda in the internals of Arrow.
It's implementation identity<A>().doWhile(predicate)
but for example linear<A>().doWhile
will have A
as Input
and Duration
as Output
.