by munificent · 11y ago · 0 comments
> The most straightforward way to represent the proposition
> “not A” with the type A -> ⊥, where ⊥ is what’s called an
> empty type – a type with no values. (This type’s symbol
> comes from mathematics. It is usually pronounced
> “bottom.”) A -> Void can be read as “if we have an A, we
> can use it to make something that doesn’t exist”
Unless the author means something different from what I think, using "void" here is very confusing. "void", as it appears in C, Java, et. al. is not all like a bottom type. A bottom type means "there can be no value here". In other words, a function whose return type was bottom could not return. Coming from an imperative mindset, one way to understand that is to consider this function: foo() { throw "!"; }
You can never get a value out of this function. If you do: var result = foo();
result will never get assigned. So, here, foo's return type really is "bottom". This is different from void—a function that returns successfully but emits no value.Instead of corresponding to "bottom", void maps to the unit type: the empty tuple.
You are trying to equate mathematical functions and software functions (i.e. co-routines). They are not the same thing.
A co-routine does not have a domain and co-domain. When we declare a function type
F(T_1, T_2) T_3, T_4, ... {}
we are saying that a co-routine begins in a pair type (T_1, T_2), it ends in a function type (return) mapping the T_3 and T_4 values to a pair type (Pointer, Data) for both values (as a simplified view).
> So, here, foo's return type really is "bottom".
No, the return co-routine is a routine that finishes successfully but "emits" no value. There are no bottom or unit types anywhere in this. Sorry.
The article uses "⊥" in one sentence and "Void" in the next without clarifying if "Void" is synonymous with bottom or if a new concept is being introduced.
Either way, my point was that programmers coming from the large slew of Algol68-derived languages will see "void" here and likely think it has something to do with the "void" they're familiar with when it does not.
As far as I know, in practice, "void" in C, Java, et. al. works more like the unit type than a bottom type and/or this not-very-well-defined-by-the-article void type.
If I'm wrong, I'd like to know more, but preferably in language a little more familiar to a working programmer than describing software functions as "co-routines which do not have a domain and co-domain".