Hi! I'm wondering why either{} is a suspend functi...
# arrow
p
Hi! I'm wondering why either{} is a suspend function. I read above, that Either::catch is no longer a suspend function and would like to know if the same is true for either {...} For me that is one of the biggest flaws of Arrow as Either is a central concept and I always have to cope with suspend even when most of the code is pure.
y
either
is usually intended to be used in suspending contexts and so by default that's what you first see. However IIRC there's
either.eager {}
that has the same exact comprehensions benefit of
either {}
but doesn't require to be called in a
suspend
function (because it internally uses
@RestrictsSuspension
to still be able to use delimited continuations to do the whole comprehensions and fail-fast bazzaz without allowing you to callnormal `suspend fun`s in an unsafe context.
👌🏼 4
p
Was not aware about that! Thanks a lot!
y
No problem. Don't hesitate to ask if you face any more problems!
🔝 1