``` object test { sealed class BizError { ...
# arrow
r
Copy code
object test {

    sealed class BizError  {
        object Error1 : BizError()
        object Error2 : BizError()
        object Error3: BizError()
    }

    val ops: List<ValidatedNel<BizError, Int>> = listOf(
            1.validNel(),
            1.validNel(),
            1.validNel(),
            BizError.Error1.invalidNel(),
            BizError.Error2.invalidNel(),
            BizError.Error3.invalidNel()
    )

    val result: ValidatedNel<BizError, Int> = ops.reduce { a, b ->
        a.combine(b, NonEmptyList.semigroup())
    }
}
Similar but there is syntax for ValidatedNel to lift values into its context. @pguardiola repo has a good example. https://github.com/Guardiola31337/uiagesturegen/blob/master/uiagesturegen/src/main/kotlin/com/pguardiola/uigesturegen/dsl/interpreter.kt#L36
You use combineK to automatically accumulate errors using the nonenptylist semigroup.
Uiagesturegen is a free applicative DSL interpreted to Validated
p
There's also the "fail fast" approach, a different interpreter which interprets to Either
👍 1