I'm working with a bunch of traditional functions ...
# arrow
p
I'm working with a bunch of traditional functions - I can
catch
to get a
Either<Throwable, *>
from a function that may throw. I'm looking for the reverse. I want to throw if right. Should I just create an extension function?
s
Yes, we purposely do not expose such functions from Arrow-Core. We might consider exposing it from Arrow Fx Coroutines like we do for
IO<Either<Throwable, A>> => IO<A>
. Since
Either<Throwable, A> => (suspend () -> A)
is a pure transformation.
k
I want to throw if right
Does that mean throwing an exception in case you get the right value? (Aka not an left side of the either which is the exception?)
p
Sorry, mistyped. I meant left. And yes, makes sense Simon.