3 ms·
Let's say you have a type L (for letters) with values A and B, and you have another type N (for numbers) with values 1, 2 and 3. The sum type L + N is composed
by pdpi 2y ago
Let's say you have a type L (for letters) with values A and B, and you have another type N (for numbers) with values 1, 2 and 3.
The sum type L + N is composed of the values A, B, 1, 2, 3. It's a set union, and the cardinality of the union is the sum of the two cardinalities.
Likewise, the product type L x N has the values (A, 1), (A, 2), (A, 3), (B, 1), (B, 2), and (B, 3). It's the usual cartesian product of sets, and you get the cardinality of that type by multiplying the two cardinalities.
(For bonus points: The type of functions L -> N is an exponential type, with cardinality N^L)