mitch
09/26/2022, 2:34 PMList<T> -> Option<NonEmptyList<T>>
? was it missed?
Context, I found out NonEmptyList.fromList
is now deprecated in favour of nullable types list.toNonEmptyListOrNull()
which is quite verbose. In our kotlin projects, we favour Option<T>
and we don’t use nullable types, hence now we will need to do a list.toNonEmptyListOrNull().toOption()
which is even more verbose.. I wonder if there’s any objections if I raise a PR to introduce list.toNonEmptyListOrNone()
? or a shorter one such as list.toNelOrNone()
raulraja
09/26/2022, 2:38 PMOption
we should support it in the same way we do with nullable types. Having said that we only recommend people use Option in those cases where you are doing interop with a system that uses null
as value signal like in the case of RxJava
and other java libraries. On a different topic there are some efforts to make Option leaner https://github.com/arrow-kt/arrow/pull/2780simon.vergauwen
09/26/2022, 2:38 PMtoNonEmptyListOrNull().toOption()
causes 0 overhead we saw this as a good solution.
I think toNonEmptyListOrNone
can fit into Arrow though, we're also considering keeping orNull()
and orNone()
I think for the other APIs in 2.0.mitch
09/26/2022, 2:50 PMMono
it will literally create an empty mono which will hang in production, indefinitely until killed. Jackson, also, to my knowledge can’t deserialize value classes https://github.com/FasterXML/jackson-module-kotlin/issues/199 so this will break.. everything.simon.vergauwen
09/26/2022, 2:52 PMOption
will remain with it's current encoding.mitch
09/26/2022, 2:54 PMsimon.vergauwen
09/26/2022, 2:56 PMthanh
09/26/2022, 3:02 PMYoussef Shoaib [MOD]
09/26/2022, 9:20 PMnull
at all, even if you put a null inside of it (it uses a special underlying data class). This was a very conscious decision since (without going into too much detail) the compiler optimizes an Option<T>?
Only if Option's underlying type is non-nullable. Additionally, if you use it with a Mono
, I believe it will just simply be boxed, so no worries there either. On Jackson not serialising value classes, that is a very real issue, but it is one that hopefully should be fixed soon enough.