```listEithers.map { it.toDomain() }.traverse(Eith...
# arrow
c
Copy code
listEithers.map { it.toDomain() }.traverse(Either.applicative(), ::identity).map { it.fix().toList() }
vs
Copy code
listEithers.map { it.toDomain() }.traverseEither { it }
s
Yes, those examples are equivalent. I wonder what type
listEithers
is.
listEithers.traverseEither { it.toDomain() }
should also be possible.
🔝 1
traverseEither { it }
==
sequenceEither()
👍 1
c
Copy code
virtual.traverseEither { it.toDomain() }
                    .flatMap { virtuals ->
                        physical.traverseEither { it.toDomain() }
                            .map { physicals ->
                                AccountState.CardCreated.MultipleCard(virtuals, physicals)
                            }
                    }
do there are a more idiomatic way to build this?
s
You could write this with
zip
(or
either { }
).
Copy code
virtual.traversEither(::toDomain)
  .zip(physical.traverseEither(::toDomain))
  { vs, ps ->
    CardCreated.MultipleCard(vs, ps)
  }
c
yeah! Thanks Simon i learn a lot with you 🙇‍♂️
2
🙌 1