Hi there. I am struggling a little with using the
Ior
type.
Let's say I have some code that needs to be resilient but should log unexpected behavior:
fun foo(): Int {
println("Something unexpected happened and I want to proceed")
println("Another unexpected thing happened and I still want to proceed")
return 42
}
I want my function to have no side-effects to be able to test it more thoroughly.
Ior
seems to be a perfect match, but I am quite unhappy how my code turns out.
fun foo2(): Ior<NonEmptyList<String>, Int> = iorNel {
Ior.Both("Something unexpected happened but I still want to proceed".nel(), Unit).bind()
Ior.Both("Another unexpected thing happened but I still want to proceed".nel(), Unit).bind()
42
}
Is there a better way of writing this?