hi, I have the need to call a suspending function ...
# arrow
t
hi, I have the need to call a suspending function from Either.flatMap() I understand the recommendation to use IO in this case, however I'm not a big fan of using Throwable as the error type, rather than my own sealed class. Is there anything particularly wrong with working around this via an extension function? i.e.
Copy code
suspend fun <A, B, C> EitherOf<A, B>.flatMapSuspend(f: suspend (B) -> Either<A, C>): Either<A, C> =
    fix().let {
        when (it) {
            is Either.Right -> f(it.b)
            is Either.Left -> it
        }
    }
y
You could probably use an IO of Either with a transformer
t
Copy code
either{
    someEither.bind().let{ someSuspendingStuff(it) }.bind()
}
this works 🙂
👍 1
t
thank you - the new either {} syntax is wonderful
arrow 2