I am having trouble refactoring this function here. How can I make it functional, in a way that instead of nested when-is you have sequential mappings/aggregations of LEFT=ErrorCodes? And if I wanted to add a try-catch-block to it, how would I make that functional? I am using 1.2.0-RC but have no objections downgrading it.
when(val maybeValid = ValidInput.create(uncheckedInput)) {
is Either.Right -> {
val validInput = maybeValid.value
when(val maybeResult = Result.create(validInput)) {
is Either.Right -> {
TRY/CATCH, RETURN LEFT ON CATCH, RESULT ON RIGHT
}
is Either.Left -> { RETURN LEFT })) }
}
}
is Either.Left -> maybeValid.leftOrNull()!!.map { RETURN LEFT }
}
I am just a bit overwhelmed of the toolset Arrow offers, originally I was just using Either as an advanced tuple, but I might as well aggregate the results in the way it is meant to be used.