Sum types are a way to define a type that can be one variant of a finite number of types. It originates from category theory, where it is called a coproduct. In programming languages, it is also known as a tagged union, variant, or discriminated union.
Some languages have a built-in syntax for sum types, like Rust, Haskell and Elm. In the example below I'll show a sum type in form of an Animal using Rust.
enum Animal {
// Name
Dog(String),