Let's play a game! Record or variant?
The we need to pay attention to the conjunctions here. When we use "or," we generally want a variant, while when we use "and," we generally want a record or tuple.
We can call these one-of types and each-of types.
Records and Tuples are types of each-of types, while variants are types of one-of types.
Each of types are often also known as product types, and variants are often also known as sum types.
Variants are also known as tagged unions. We can model them like this:
type string_or_int =
| String of string
| Int of int
But it's more than this! We can have two of the same types
type blue_or_red_int =
| Blue of int
| Red of int
This is known in mathematics as a tagged union.
These data types are called algebraic data types (because sums and products 😊)
The abbreviation is "ADT," which unfortunately has a name clash with "Abstract Data Types"