In the previous chapter, we saw how to build values that capture multiple types of values together, and the different ways that we can build those types. This lets us say that we have a value of the composite (product) type only if we have all of the values of their composed types. Sometimes though, we need values that must be only one type out of several types.
In this chapter, we will cover these only one types, namely:
- Variant types
- Polymorphic variant types
- Generalized algebraic data types
Collectively, these types are known as sum types because the number of possible values that a sum type can contain is the sum of the number of possible values of each of its component types. We'll see how this is true in this chapter!