Defining Your Own Type

You can define your own type, by assigning a type expression to a name. The syntax is this:
type ‹name› = ‹type expression›.

The simplest type is just a arbitrary letter sequence, which is call “type constructor”. A type constructor's first letter must be Capitalized.

(* example of defining types. *)typet1 = X;;typet2 = Alice;;(* above defines a type named “t1”, and values of this type is just the symbol
“X”. And “t2” another type. The items belonging to this type is just the symbol “Alice”. *)
X;;(* evaluate X *)

Type expression can use the operator |, which means “alternative”, “one of”, or “or”.