Hi :wave: , another migration question from `0.11....
# arrow
j
Hi 👋 , another migration question from
0.11.0
to
0.13.1
. How would I write this function now:
Copy code
suspend fun buildPerson(): Either<DomainError, Person> {
    val name: Either<DomainError, Name> = getName()
    val address: Either<DomainError, Address> = getAddress()
    val dob: Either<DomainError, Date> = getDOB()
    return Either.applicative<DomainError>().tupledN(name, address, dob).map {
        Person(name = it.a, address = it.b, dob = it.c)
    }
}
Follow-up: Can I accomplish this in parallel (assuming
get*
function are
suspending
)?
r
Hi @Josh, It may look like this:
☝️ 1
👍 2
j
thank you!
s
Without parallelisation it would look like the following:
Copy code
fun buildPerson(): Either<DomainError, Person> =
  getName().zip(
    getAddress(),
    getDOB()) { name, address, dob ->
      Person(name, address, dob)
  }
Or you could user
either { }
of course also.
👍 2
👏 1