https://kotlinlang.org logo
#arrow-contributors
Title
# arrow-contributors
k

kartoffelsup

03/10/2019, 7:39 AM
Sorry for the stupid question:
Copy code
fun <E, A> Kind<F, A>.withRetry(err: E, AE: ApplicativeError<F, E>, retries: Int) =
  if (retries == 0) AE.raiseError(err)
  else AE. run { this.handleErrorWith { withRetry(it,AE, retries - 1) } }
Wouldn't that just call itself until 0 without any other possible outcome?
p

pakoito

03/10/2019, 12:38 PM
that withRetry call is inside a lambda that’s called lazily
it won’t be called unless
this
fails
because
IO
is a lazy, suspended datatype
for eager datatypes…yeah it may stackoverflow if they’re unrecoverable errors and retries is large enough
3 Views