`handleErrorWith` ?
# arrow
p
handleErrorWith
?
m
I'll check that out. Thanks
👍🏼 1
p
your implementation can be done (less optimally) using
swap().flatMap(block)
m
Looks like handleErrorWith() preserves the same type of failure (the left type)
p
ye, you're correct
m
I should use swap().flatMap(block).swap(). But then I'd lose the inlining, and I need that because I'm running suspend functions inside that block.
p
oooooh
cheeky
flatMapLeft
is a good name for this. I'm trying to remember why we didn't allow to change the error type on flatMap
I'm sure it's because the MonadError instance is fixed to one error type
which..makes sense
m
processFlow
is a builder of
ProcessFlow
which is something like a kotlin
Flow
emitting progress events, followed by a terminal event containing a result. The ``as`` infix operator embeds a ProcessFlow in the current
ProcessFlow
.
ProcessFlow
is actually a wrapper around a regular
Flow
, and that's where the need for using
suspend
functions comes from.
Thanks, Paco!
p
I would split the operation in two
the fold inside
flatMapLeft
could happen outside
where you have access to suspend
doNotCompute? StoredEvaluationProblem.ComputationSkippedAsRequested.left() : computeFlow()
hmmm
meh I'm overthing it
I didn't need the `Option<T>.`if`` after all: https://gist.github.com/mel4tonin4/a4257b83a4f609474a78471b21639ad2. This is the best I can do without using metaprogramming, I guess. If I keep using this
ProcessFlow
, I'll check arrow-meta and see if I can remove some boilerplate code (not visible here) and simplify the syntax even further. Anyway, thanks again!