Open sampengilly opened 1 month ago
Looking at it again. I don't think that zipOrAccumulate
makes sense for IorRaise
as it's essentially an applicative, the final builder block only makes sense if all of the inputs have succeeded, there doesn't seem to be any room for a partial success that can be represented by an Ior
in that case.
Add support for mapOrAccumulate functions which when run inside an
IorRaise
scope accumulate errors into aBoth
case with the combined errors and any successfully mapped items.This change adds the basic
mapOrAccumulate
functions, it doesn't provide any additional convenience functions like those which take anIterable<T>
receiver such as those found inIterable.kt
. As I see it, in order to provide those functions we'd either need to wait for context parameters, or move each of those existing functions into theRaise
interface and define the new ones in theIorRaise
class.I also haven't included the
zipOrAccumulate
functions in this change. I intend to do those as it feels like a use case which makes sense (carry out N operations, collect the errors, but if some succeeded then treat it as a success overall).