MLton 20100608 TypeConstructor
Home  Index  
In Standard ML, a type constructor is a function from types to types. Type constructors can be nullary, meaning that they take no arguments, as in char, int, and real. Type constructors can be unary, meaning that they take one argument, as in array, list, and vector. A program can define a new type constructor in two ways: a type definition or a datatype declaration. User-defined type constructors can can take any number of arguments.
datatype t = T of int * real            (* 0 arguments *)
type 'a t = 'a * int                    (* 1 argument *)
datatype ('a, 'b) t = A | B of 'a * 'b  (* 2 arguments *)
type ('a, 'b, 'c) t = 'a * ('b  -> 'c)  (* 3 arguments *)

Here are the syntax rules for type constructor application.


Last edited on 2005-12-02 04:26:23 by StephenWeeks.