, now i’m bumping Arrow version and I wanted to try using null as much as possible. Is there any elegant way to use semigroup to concatenate
NonEmptyList<Stuff>?
c
CLOVIS
12/29/2022, 3:43 PM
Can't you just
list1?.plus(list2)
?
CLOVIS
12/29/2022, 3:45 PM
Oh, no, because
list2
could be empty
Then:
Copy code
operator fun <T> NonEmptyList<T>?.plus(other: NonEmptyList<T>?): NonEmptyList<T>? {
val first = this ?: return null
val second = this ?: return null
return first + second
}
g
Giulio Caccin
12/29/2022, 3:47 PM
yes i could, and we did somewhere, but that function is also inside maybeCombine of the semigroup, and i was asking because i thought there was a way to use semigroups for that