Jakub Pi
08/04/2020, 3:54 PMEither.catch()
but it expects (Throwable) -> L
where I have an sealed hierarchy which stores a reference to the underlying Exception, which I can't easily pass in if I only have a handle to Throwable. It's also expecting a suspend function which is throwing a spanner into the works.
I've tried Either.functor().lift()
but can't quite figure out how to make it work. Right now I have an Either<Data,Data>
. I'm sure there's a way to combine the two functions and probably a third one I don't know about to get the result I want.
Is there some sample code for a similar use case or am I taking the wrong approach?PhBastiani
08/04/2020, 4:29 PMJakub Pi
08/04/2020, 6:58 PMEither.catch()
here but not quite what I'm looking for. Basically looking for an example of a lift()
PhBastiani
08/04/2020, 9:04 PMsuspend fun read() : Either<E, A> = ...
suspend fun A.process() : Either<E, B> = ...
suspend fun readAndProcess(): Either<E, B> =
Either.fx {
val data= !read()
val processed = !data.process()
processed
}
again with the new api (i.e. more concise than with IO<Either<E, A>>)