-
Hey! If I use What I do now, I convert |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello 🙂 First, sorry for the delay, I somehow completely missed your issue 😞 If I understand correctly, you are trying to do the following: pipe(
someIOEither,
IOEither.getOrElse(() => null),
...do something with the A | null from the IOEither
) And because it doesn't work, you are going through the trouble of converting your The problem you are having is that I think you then have two options:
pipe(
someIOEither,
IOEither.getOrElseW(() => IO.of(null)), // <= notice that you have to provide null wrapped in an IO, hence the IO.of(...)
...do something with the resulting IO<A | null>,
)() // <= run the IO to get the result
pipe(
someIOEither(), // <= run the IO immediately
Either.getOrElseW(() => null), // <= notice we use Either<E, A> instead of IOEither<E, A> as the IO is already performed
...do something with the resulting A | null,
) I hope that makes sense, please don't hesitate to reach out again if that wasn't clear enough 🙂 |
Beta Was this translation helpful? Give feedback.
Hello 🙂
First, sorry for the delay, I somehow completely missed your issue 😞
I still hope you'll find the (late) answer useful.
If I understand correctly, you are trying to do the following:
And because it doesn't work, you are going through the trouble of converting your
IOEither
to aTaskEither
(I assume because you are more comfortable with the latter?) which makes your computationasync
.The problem you are having is that
IOEither<E, A>
is just sugar forIO<Either<E, A>>
and thegetOrElse
only applies to the innerEither
, collapsing the whole thing into anIO<A>
that you can…