Unions
A.k.a. Discriminated Unions (DU)
Key points
type Ticket =
| Adult // no data -> β singleton stateless
| Senior of int // holds an 'int' (w/o more precision)
| Child of age: int // holds an 'int' named 'age'
| Family of Ticket list // holds a list of tickets
// recursive type by default (no 'rec' keyword)Cases naming
Field labels
Instantiation
Name conflict
Unions: get the data out
Single-case unions
Enum style unions
Unions .Is* properties
Last updated