Sums and Types in Programming Languages

It turns out that some of those equations also hold for the type systems of many programming languages.

Zero, or the empty set, corresponds to an empty type.

Plus, or union, corresponds to a type constructor that allows values of several different types to belong to the sum type.

Times, or product, corresponds to a type constructor that allows values of several different types to be combined into a single value of the product type.

Consider the C programming language.

In C, what corresponds to 0?
The void type.

In C, what corresponds to +?
The union type constructor.

In C, what corresponds to ×?
The struct type constructor.

Now consider Java.

What corresponds to 0?
The Void pseudo-type.

What corresponds to +?
Abstract classes and interfaces.

What corresponds to ×?
Concrete subclasses and classes that implement interfaces.

For debugging: Click here to validate.