Previous Contents Next

3.5   Type expressions

typexpr ::= type-ord
  | type-rec
type-ord ::= ' ident
  | ( type-ord )
  | type-tuple
  | type-tuple ->   type-tuple
  | full-typeconstr-name
  | type-ord   full-typeconstr-name
  | ( type-ord   { , type-ord } )   full-typeconstr-name
type-tuple ::= < >
  | < type-ord   { * type-ord } >
typrec ::= type-ord where   type-defs
type-defs ::= ' ident =   typtop   { and ' ident =   typtop }

The table below shows the relative precedence and associativity of operators and non-closed type constructions. The constructions with higher precedence come first.
Operator Associativity
Type constructor application --
* right
< --

Type expressions denote types in compilation unit interfaces. They occur in the type declaration of values.

Type variables

The type expression ' ident stands for the type variable named ident . In abstract data type declarations, type variables are names for the data type parameters. In value type declarations, they represent unspecified types that can be instantiated by any type.

Parenthesized types

The type expression ( type-ord ) denotes the same type as type-ord .

Port types

The type expression < type-ord 1 *   type-ord 2 * ... *   type-ord n > denotes the type of an asynchronous port name carrying n arguments of type type-ord 1, type-ord 2,...type-ord n.

The type expression
< type-ord 1 *   type-ord 2 * ... *   type-ord n > -> <   type-ord n+1 *   type-ord n+2 * ... *   type-ord n+m >
denotes the type of an synchronous port name carrying n arguments of types type-ord 1, type-ord 2,...type-ord n, and giving back m results of types type-ord n+1, type-ord n+2,...type-ord n+m.

Constructed types

Type constructors with no parameter, as in full-typeconstr-name , are type expressions.

The type expression type-ord   typeconstr , where full-typeconstr-name is a type constructor with one parameter, denotes the application of the unary type constructor full-typeconstr-name to the type type-ord .

The type expression ( type-ord 1 ,... ,   type-ord n )   full-typeconstr-name , where full-typeconstr-name is a type constructor with n parameters, denotes the application of the n-ary type constructor full-typeconstr-name to the types type-ord 1 through type-ord n. Parenthesis are optional when n equals one.

Recursive types

The type expression type-ord where '   ident 1 =   typtop 1 and ... and '   ident n =   typtop n denotes the same type as type-ord , and also binds the type variables ident 1, ..., ident n to the types typexpr 1, ...typexpr n, both in type-ord and in typexpr 1, ...typexpr n. When one of the type variables ident i actually occurs inside one of the type expressions typexpr j, a recursive type is created.
Previous Contents Next