<@U4UGS5FC7> <@UM95PD31P> why do we have type `Not...
# arrow
r
@raulraja @Rachel why do we have type
Nothing
in this:
fun <A> absurd(): (Nothing) -> A
, but not
Unit
? https://github.com/arrow-kt/Category-Theory-for-Programmers.kt/blob/master/src/main/ank/1.5-products-and-coproducts.md Like it is written in CTfP book: "In the category of sets and functions, the initial object is the empty set. Remember, an empty set corresponds to the Haskell type Void (there is no corresponding type in C++) and the unique polymorphic function from Void to any other type is called absurd" So
Nothing
in Kotlin is the initial type for everything else?
s
It's called
absurd
because you can never call it. And you can not call it because there are no instances of type Nothing. We do have a single Unit instance in Kotlin
☝🏼 1
🤔 2
p
fun <A> absurd(Nothing): A
r
absurd / undefined closest is TODO() in Kotlin
Nothing is bottom of all types and also a subtype of all types as Stojan said with no inhabitants. The only way to write a non suspend function that returns Nothing is throwing an exception since we can't construct or obtain a value of Nothing.
Suspended functions can exit with Nothing without throwing though by shifting in their scope
👌 1