3 ms·
> If we know that the set has a maximum cardinality of 1, then we have reinvented the Optional/Maybe type: it either contains a value or it does not. unit has
by masklinn 9y ago
> If we know that the set has a maximum cardinality of 1, then we have reinvented the Optional/Maybe type: it either contains a value or it does not.
unit has a cardinality of 1, it has a single value (). Option types have a cardinality of 1 (if you ignore the sub-value): an empty value and a full value. This can trivially be shown by the bijection between boolean and unit option.
> In an implementation language like Java, Objective-C or Ruby, a null value is supplied as a bottom type
1. Ruby's nil is just a singleton instance of NilClass, and it's not a subtype of "all other types in the system" anymore (or less) than Fixnum or String is.
2. a bottom type is empty by definition, null can't be a "bottom type" since it's a value (of sorts). `void` would be a bottom if it were something approaching a proper type.