Steven Sherry
03/17/2020, 1:37 PMList<ValidatedNel<E, A>>
and I’m converting that to a ValidatedNel<E, List<A>>
. Is there a more idiomatic way of doing that? The actual flow of data is more like this: List<A> -> List<ValidatedNel<E, B>> -> ValidatedNel<E, List<B>>
. It works, but it feels like there is probably something more “native” to arrow that would handle this kind of flow.aballano
03/17/2020, 1:41 PMSteven Sherry
03/17/2020, 1:45 PMSteven Sherry
03/17/2020, 1:45 PMsimon.vergauwen
03/17/2020, 1:45 PMval aas: List<A> = listOf(...)
val validated: List<ValidatedNel<E, B>> = aas.map(::validate)
val res: ValidatedNel<E, List<B>> = validated.sequence(Validated.applicative(NonEmptyList.applicative()).map { it.fix() }
OR
val aas: List<A> = listOf(...)
aas.traverse(Validated.applicative(NonEmptyList.applicative()) { a ->
validate(a)
}.map { it.fix() }
Steven Sherry
03/17/2020, 3:05 PM