phldavies
04/22/2025, 11:46 AMList<A>.asNonEmptyListUnsafe() that avoids copying and simply wraps the list (potentially with a require(isNotEmpty()) check? (same for NonEmptySet) - currently the suggested replacement for the old Nel.fromListUnsafe is list.toNonEmptyListOrNull() ?: error(...) however this currently iterates the list twice (effectively doing iterator().let { listOf(it.next()) + Iterable { it }.toList() })phldavies
04/22/2025, 11:48 AMYoussef Shoaib [MOD]
04/22/2025, 12:02 PMkotlinx-immutable-collections may be worth it for Arrow? After all, it's an FP library, so immutable collections make sense. Anyone working with a NonEmptyList likely wants it to be immutable anyways. If we did that, we could then use toImmutableList and not even need an unsafe method at all.phldavies
04/22/2025, 12:10 PM@OptIn annotation would allow for a clean integration point for kotlinx-immutable-collections without couplingAlejandro Serrano.Mena
04/22/2025, 5:48 PMkotlinx-immutable, what about having an arrow-core-immutable which wraps those versions? That way people don't need to depend on the immutable library if they don't want...Alejandro Serrano.Mena
04/22/2025, 5:48 PMphldavies
04/22/2025, 5:50 PM