Why can’t I call `Either.catch()` from inside `Eit...
# arrow
e
Why can’t I call
Either.catch()
from inside
Either.fx { }
? …I see an error about restricted suspending functions, but I don’t understand how to see what can be called from within
Either.fx { }
…I am currently getting around the problem by doing this, but I don’t know if it is safe to do:
Copy code
fun <L, R> Either.Companion.catchSafely(
    mapper: (Throwable) -> L,
    block: () -> R): Either<L, R> =
    runBlocking {
        catch(
            suspend  { block() }
        )
    }.mapLeft(mapper)
r
You can by flagging thew containing function as suspend
all side effects in Arrow need to be suspend and Either.catch deals with arised exceptions.
Without it being it suspend it can’t be guaranteed it’s pure.
e
OK, thanks