simon.vergauwen
07/19/2019, 4:01 PMleftFlatMap
but that currently doesn’t exist in Arrow.Robert Menke
07/19/2019, 6:00 PMflatMapLeft
I did create a branch with the functionality + test. I get an error pushing my branch up to origin because of permissions. No big deal if you’d prefer not to add extra code to maintain @simon.vergauwen @pakoito. Up to you guys.pakoito
07/19/2019, 6:00 PMpakoito
07/19/2019, 6:01 PMsimon.vergauwen
07/19/2019, 6:01 PMhandleErrorWith
simon.vergauwen
07/19/2019, 6:02 PML
but rather leaves it generic.simon.vergauwen
07/19/2019, 6:03 PMRobert Menke
07/19/2019, 6:04 PMhandleErrorWith
does work perfectly for my use case so I can stick with that. Thanks for pointing me in the right direction!pakoito
07/19/2019, 6:04 PMflatMapLeft
is a specialized handleErrorWith
pakoito
07/19/2019, 6:05 PMsimon.vergauwen
07/19/2019, 6:05 PMpakoito
07/19/2019, 6:05 PMpakoito
07/19/2019, 6:05 PMsimon.vergauwen
07/19/2019, 6:06 PMfun <A, B, C> Either<A, B>.leftFlatmap(f: (A) -> Either<C, B>): Either<C, B> = when(this) {
is Either.Left -> f(this.a)
is Either.Right -> this
}
fun <A, B> Either<A, B>.handleErrorWith(f: (A) -> Either<A, B>): Either<A, B> = leftFlatMap(f)
simon.vergauwen
07/19/2019, 6:06 PMleftFlatMap
to come back when we complete the bifunctor hiearchy.simon.vergauwen
07/19/2019, 6:07 PMIO<E, A>
over handleErrorWith
simon.vergauwen
07/19/2019, 6:07 PME
to Nothing
, well I guess you could name it handleErrorWith
in a bifunctor hierarchy but then it would be an alias. Here it’s not.simon.vergauwen
07/19/2019, 6:12 PMRobert Menke
07/19/2019, 6:18 PMhandleErrorWith
is not an inline
function so it actually doesn’t work for my use case because I need to call suspend
functions inside. I can get by with fold
for now, just voicing my experience.simon.vergauwen
07/19/2019, 6:20 PMIO
comes in, Either
cannot deal with the powers of suspend
. It cannot control the async jumps, exception being thrown etc.Robert Menke
07/19/2019, 6:21 PMflatMap
or fold
but not something like handleErrorWith
?simon.vergauwen
07/19/2019, 6:21 PMIO
you'd do io.handleErrorWith { e -> IO.effect { suspendFunction() } }
simon.vergauwen
07/19/2019, 6:22 PMRobert Menke
07/19/2019, 6:28 PM