There's an interesting contrast between andtypes and ortypes,
if you count the values produced by these type constructs.
Consider an andtype that indicates a time of the week in
days and hours. (& Day_of_Week & Hour_of_Day &) where the
Day_of_Week type has the obvious 7 possible values and
the Hour_of_Day type has 24 possible values. An example
value would be
(& tuesday & eighth_hour &)
There are 7 X 24 = 168 possible values of this type.
Consider on the other hand an ortype composed from the
same two types.
( Day_of_Week  Hour_of_Day )
A type similar to this might be used in the process of
composing a messaging system which reports simplified times
such as "yesterday" and "this morning". Example values
would be
(x <+ tuesday$x) or (x <+ eighth_hour$x)
There are 7 + 24 = 31 possible values of this type.
Note the special cases of these type constructs.
The type (& Day_of_Week &) and ( Day_of_Week ) both
have 7 values, as the results of adding up "7" and the
result of multiplying together "7" are the same.
Every value of an ortype must designate one of the
component types and a value of the designated type.
But type () has no component types, so it can have
no values. This corresponds to the fact that
adding up no numbers yields "0".
The (&) type is, naturally, different. A value of an andtype must
designate a value for each component type. Since there are no
component types it is trivial to satisfy this requirement. That
trivial value is the only possible value of this type. It is denoted
(&) . Most people are unfamiliar with what you get by multiplying
together zero numbers. The result is 1. That corresponds to the (&)
type having 1 value.
Because of the relationships to addition and multiplication, ortypes
and andtypes are often called sum types and product types
respectively. The OCaml language even uses the multiplication (* )
symbol to denote andtypes.
Similar to the (&) and () types are Ambidexter's True and False types.
The latter types also have 1 and 0 values respectively.
The builtin name for the one value of type True is void . The rationale is that the void value conveys no information.
