type namedInt = (string * int);
val xBinding:namedInt = ("x", 15);

(* Simple "enumeration" *)
datatype Colors = Red | Orange | Yellow
                | Green | Blue | Indigo
                | Violet;

(* A type with components *)
datatype MyNumber = MyInt of int
                  | MyReal of real;

(* A recursive type *)
datatype StringTreeNode = 
    Nothing
    | StringTreeNode of string * StringTree
                               * StringTree;

(* A recursive polymorphic type *)
datatype 'a Tree =
    NullNode
    | TreeNode of 'a * 'a Tree * 'a Tree;

(* Instantiating a tree node *)
val oneTree = TreeNode(4,
                  TreeNode(2, NullNode, 
                              NullNode),
                  TreeNode(7, NullNode, 
                              NullNode));

Last modified: Wed Apr 4 21:58:48 PDT 2001