23.4 Type declaration : typDecl
Type declaration define a name of a type. Its syntax is given below.
typeDecl | := | type typbind |
tybind | ::= | tyvarSeq tycon = ty and tybind |
23.4.1 type specification : typSpec
Interface of type declaration is either type specification or opaque type specification. Syntax of type specification is the same as type declaration. Opaque type specification has the following syntax.
opequeTypeSpec | := | type tyvarSeq tycon ( = runtimeTypeSpec ) |
runtimeTypeSpec | := | tycon {} * -> |
If the type is implemented by a record type, tuple type, or function type, runtimeTypeSpec must be {}, *, or ->, respectively. Otherwise, runtimeTypeSpec must be the type constructor that implements the type. runtimeTypeSpec may not be identical to the implmentation type if the runtime representation of runtimeTypeSpec is matched with that of the implementation type. See Chapter 29 for details of the runtime representation.
23.4.2 Examples
The following are examples of type declarations and their interface.
Data.sml file:
type ’a set = ’a list
type ’a queue = ’a list * ’a list type index = int type id = int Data.smi file: type ’a set (= list) type ’a queue (= *) type index = int type id (= int) |