tags : Programming Languages, Ocaml

## One of / Each of/ Maybe (Ocaml)

`One-of types`

are more commonly known as`sum types`

`each-of types`

as more commonly known as`product types`

.

### One of

- Ocaml Variants are like disjoint union
- Aka
`tagged union`

- Variants are also known as
`Algebraic Data types`

- Each value of a variant comes from one of many underlying sets
- Thus far each of those sets is just a single constructor hence has cardinality one
- Disjoint union is indeed sometimes written with a Σ operator.
- OCaml variants actually combine several theoretically independent language features into one: sum types, product types, recursive types, and parameterized (polymorphic) types.
- Resources

### Each of

- Ocaml Tuples/records are like Cartesian product
- Each value of a tuple or record contains a value from each of many underlying sets.
- Cartesian product is usually written with a product operator Π or x

### Maybe

- Ocaml
`option`

are maybe types