what would be the best way to recover from an `Ior...
# arrow
m
what would be the best way to recover from an
Ior.Left
? I have an existing value using which I want to transform a subsequent
Ior.Left
into an
Ior.Both
- but all the approaches I have found look quite clumsy. I prefer using the Raise DSL so my expression currently looks like this:
Copy code
ior({ a, _ -> a }) { // this simple scenario only produces one relevant Left value
    val result = op1ReturnsEither().bind()
    op2ReturnsIor().fold( // the Right side of this operation in this context will be the same as result from op1, so it can be ignored.
        fa = { Ior.Both(it, result) },
        fb = { Ior.Right(result) },
        fab = { err, _ -> Ior.Both(err, result) }
    )
}.flatten { a, _ -> a } // same issue as above
I'm pretty sure there is a better - i.e. more concise or idiomatic - way, so I'm looking forward to suggestions.