rcd27
08/19/2022, 6:21 PMLukasz Kalnik
08/20/2022, 7:36 PMfilter { it.contactInfo.isRight || it.contactInfo.isBoth }
fold
in your example you have basically reimplemented filter
😉Option
types for address/email contact info in the Contact
data class? Ior
is right-biased, which means AddressContactInfo
is privileged over EmailContactInfo
.
Or is it just an abstract example?simon.vergauwen
08/22/2022, 8:16 AMior
binding for this.
ior(semigroup) {
listOf(
contactWithAddres,
contactWithMail
).map { it.contactInfo.bind() }
}
}
isLeft
short-circuits like Either.Left
but isBoth
accumulates the E
and return` Right`isRight
behaves just like Either.Right
rcd27
08/29/2022, 6:38 PMIor
was that it represent either left, or right, or both. And I still don't know how to model that by hands, Nullability of those two values means that there is a 4th case: both missing, which is not valid for this case.Ior
is not the best solution for my example, as it is right-biased, which is something I don't need.Lukasz Kalnik
08/30/2022, 6:43 AMNonEmptyList
?