Algebraic Data Type / ADT
Combination of sum types and product types
Sum Types (Or)
A value with many options
Rust Enums
enum Message {
Quit,
Move { x: i32, y: i32 },
Write(String),
ChangeColor(i32, i32, i32),
}
OCaml
type shape =
| Circle of float
| Rectangle of float * float
Product Types (AND)
A value of both types
Rust
struct Point(i32, i32);
OCaml
type point = int * int