min
09/04/2026, 7:32 AMclass Wrapper<T>(var wrapped: T)Youssef Shoaib [MOD]
09/04/2026, 8:44 AMVampire
09/04/2026, 8:45 AMmin
09/04/2026, 8:47 AMMaybe<Maybe<T>> so I can tell Nothing and Just Nothing apart. I could have used Wrapper<T?>? if it existed. I just declared my own type.Youssef Shoaib [MOD]
09/04/2026, 8:51 AMOption type instead:
sealed class Option<out T> {
val orNull: T? get() = when (this) {
is Some -> value
None -> null
}
}
data class Some<T>(val value: T): Option<T>
data object None: Option<Nothing>
Of course, Arrow already has one!min
09/04/2026, 9:11 AMOption<Option<T>> (as you’ve named it) would let me encode…
• Whether a binding (eg myParam: Option<Option<T>> = None) is not written or is assigned null
• Whether a collection (eg xs.read(i)) has no corresponding element or stores null
Kotlin uses separate sentinels (eg Iterator#hasNext) a lot because null collapses all these disparate cases. Although it needs to be interoperable with Java, so maybe that’s the best it can do. I personally prefer Option<Option<T>> to having to remember to consult whatever other things to ascertain the validity or meaning of a value.Youssef Shoaib [MOD]
09/04/2026, 9:16 AMWrapper idea was somewhat reasonable (I don't love it because it's so easy to have Wrapper<String>, which is pointless). Option is very very reasonable to have because of that nesting confusion.
Rich errors would alleviate some of the use cases for Option, but they aren't in Kotlin yet. I can expand more on that if you'd like!min
09/06/2026, 5:52 AMx.let { it }.let { it }.let { it } is pointless, as is return if (this.isValid()) true else false. Are rich errors an Arrow feature?Youssef Shoaib [MOD]
09/06/2026, 9:45 AM