``` fun <A> IO<A>.retry(count: Int): I...
# arrow
p
Copy code
fun <A> IO<A>.retry(count: Int): IO<A> =
  handleErrorWith { withRetry(it, count) }

fun <A> IO<A>.withRetry(err: Throwable, retries: Int) =
  if (retries == 0) IO.raiseError(err)
  else handleErrorWith { withRetry(it, retries - 1) }