pakoito
04/25/2019, 8:11 PMfun <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) }