Charlie Parker
Charlie Parker

Reputation: 5257

What does square brackets `[` and `]` mean in a data type definition in OCaml?

I saw the following:

type rlevel = [
| `rlevel
]

but I've never seen this before and the tutorials for ADTs (algebraic data types) are not super helpful nor is the OCaml grammar.

What does this mean?

Upvotes: 0

Views: 289

Answers (1)

octachron
octachron

Reputation: 18912

The type rlevel is a type abbreviation for a polymorphic variant type (https://ocaml.org/manual/polyvariant.html) which contains only one constructor `rlevel .

Upvotes: 1

Related Questions