Is there a more concise way to express this? I'm t...
# arrow
d
Is there a more concise way to express this? I'm taking a list of json-decoded values, using Jackson to decode them into the required types, and using
Validated
to capture conversion errors before passing the results to the target function.
Copy code
Validated.applicative(Nel.semigroup<Throwable>()).map(
                Validated.fromTry(Try { objectMapper.convertValue<A>(args[0]) })
                    .leftMap(NonEmptyList.Companion::just),
                Validated.fromTry(Try { objectMapper.convertValue<B>(args[1]) })
                    .leftMap(NonEmptyList.Companion::just),
                Validated.fromTry(Try { objectMapper.convertValue<C>(args[2]) })
                    .leftMap(NonEmptyList.Companion::just)
            ) { (a,b,c) -> f(a,b,c) }.fix()