Hi all, I was asking the other week about how/if i...
# arrow
m
Hi all, I was asking the other week about how/if it was possible to make a recursive function in the IO monad that can safely recurse infinitely (for something like a message processing loop). A few people said that this should just be inherently stack safe in async monads like IO due to how they are implemented. But the following function dies with a stack overflow exception if I run it from main with unsafeRunAsync:
Copy code
fun ioRecurseNTimes(n: Int): IO<Unit> = IO.fx {
    if (n % 1_000_000 == 0) println(n)

    if (n == 0)
        Unit
    else
        ioRecurseNTimes(n - 1).bind()
}