8
6
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
9
<META name="GENERATOR" content="hevea 1.08">
7
<META name="GENERATOR" content="hevea 1.09">
10
8
<LINK rel="stylesheet" type="text/css" href="manual.css">
9
<TITLE>Type expressions</TITLE>
16
<A HREF="manual011.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
17
<A HREF="manual008.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
18
<A HREF="manual013.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
12
<A HREF="manual011.html"><IMG SRC="previous_motif.gif" ALT="Previous"></A>
13
<A HREF="manual008.html"><IMG SRC="contents_motif.gif" ALT="Up"></A>
14
<A HREF="manual013.html"><IMG SRC="next_motif.gif" ALT="Next"></A>
21
<H2 CLASS="section"><A NAME="htoc63">6.4</A> Type expressions</H2>
23
<A NAME="@manual.kwd2"></A><BR>
25
<DIV CLASS="center"><TABLE CELLSPACING=2 CELLPADDING=0>
26
<TR><TD ALIGN=right NOWRAP>
27
<A NAME="typexpr"></A>
28
<FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT></TD>
29
<TD ALIGN=right NOWRAP>::=</TD>
30
<TD ALIGN=left NOWRAP>
31
<FONT COLOR=blue><TT>'</TT></FONT> <FONT COLOR=maroon><I><a href="manual009.html#ident"><font color=maroon><TT>ident</TT></font></a></I></FONT></TD>
33
<TR><TD ALIGN=right NOWRAP> </TD>
34
<TD ALIGN=right NOWRAP>∣</TD>
35
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>_</TT></FONT></TD>
37
<TR><TD ALIGN=right NOWRAP> </TD>
38
<TD ALIGN=right NOWRAP>∣</TD>
39
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>(</TT> <FONT COLOR=maroon><TT><a href="#typexpr"><font color=maroon><I>typexpr</I></font></a></TT></FONT> <TT>)</TT></FONT></TD>
41
<TR><TD ALIGN=right NOWRAP> </TD>
42
<TD ALIGN=right NOWRAP>∣</TD>
43
<TD ALIGN=left NOWRAP> [[<FONT COLOR=blue><TT>?</TT></FONT>]<TT><FONT COLOR=maroon><a href="manual011.html#label-name"><font color=maroon><I>label-name</I></font></a></FONT><FONT COLOR=blue>:</FONT></TT>] <FONT COLOR=maroon><TT><a href="#typexpr"><font color=maroon><I>typexpr</I></font></a></TT> <FONT COLOR=blue><TT>-></TT></FONT> <TT><a href="#typexpr"><font color=maroon><I>typexpr</I></font></a></TT></FONT></TD>
45
<TR><TD ALIGN=right NOWRAP> </TD>
46
<TD ALIGN=right NOWRAP>∣</TD>
47
<TD ALIGN=left NOWRAP> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT> { <FONT COLOR=blue><TT>*</TT></FONT> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT> }<SUP>+</SUP></TD>
49
<TR><TD ALIGN=right NOWRAP> </TD>
50
<TD ALIGN=right NOWRAP>∣</TD>
51
<TD ALIGN=left NOWRAP> <FONT COLOR=maroon><I><a href="manual011.html#typeconstr"><font color=maroon><TT>typeconstr</TT></font></a></I></FONT></TD>
53
<TR><TD ALIGN=right NOWRAP> </TD>
54
<TD ALIGN=right NOWRAP>∣</TD>
55
<TD ALIGN=left NOWRAP> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a> <a href="manual011.html#typeconstr"><font color=maroon><TT>typeconstr</TT></font></a></I></FONT></TD>
57
<TR><TD ALIGN=right NOWRAP> </TD>
58
<TD ALIGN=right NOWRAP>∣</TD>
59
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>(</TT></FONT> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT> { <FONT COLOR=blue><TT>,</TT></FONT> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT> } <FONT COLOR=blue><TT>)</TT></FONT> <FONT COLOR=maroon><I><a href="manual011.html#typeconstr"><font color=maroon><TT>typeconstr</TT></font></a></I></FONT></TD>
61
<TR><TD ALIGN=right NOWRAP> </TD>
62
<TD ALIGN=right NOWRAP>∣</TD>
63
<TD ALIGN=left NOWRAP> <FONT COLOR=maroon><TT><a href="#typexpr"><font color=maroon><I>typexpr</I></font></a></TT> <FONT COLOR=blue><TT>as</TT> <TT>'</TT></FONT> <TT><a href="manual009.html#ident"><font color=maroon><I>ident</I></font></a></TT></FONT></TD>
65
<TR><TD ALIGN=right NOWRAP> </TD>
66
<TD ALIGN=right NOWRAP>∣</TD>
67
<TD ALIGN=left NOWRAP> <FONT COLOR=maroon><I><a href="#variant-type"><font color=maroon><TT>variant-type</TT></font></a></I></FONT></TD>
69
<TR><TD ALIGN=right NOWRAP> </TD>
70
<TD ALIGN=right NOWRAP>∣</TD>
71
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT><</TT></FONT> [<FONT COLOR=blue><TT>..</TT></FONT>] <FONT COLOR=blue><TT>></TT></FONT></TD>
73
<TR><TD ALIGN=right NOWRAP> </TD>
74
<TD ALIGN=right NOWRAP>∣</TD>
75
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT><</TT></FONT> <FONT COLOR=maroon><I><a href="#method-type"><font color=maroon><TT>method-type</TT></font></a></I></FONT> { <FONT COLOR=blue><TT>;</TT></FONT> <FONT COLOR=maroon><I><a href="#method-type"><font color=maroon><TT>method-type</TT></font></a></I></FONT> } [<FONT COLOR=blue><TT>;</TT> <TT>..</TT></FONT>] <FONT COLOR=blue><TT>></TT></FONT></TD>
77
<TR><TD ALIGN=right NOWRAP> </TD>
78
<TD ALIGN=right NOWRAP>∣</TD>
79
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>#</TT></FONT> <FONT COLOR=maroon><I><a href="manual011.html#class-path"><font color=maroon><TT>class-path</TT></font></a></I></FONT></TD>
81
<TR><TD ALIGN=right NOWRAP> </TD>
82
<TD ALIGN=right NOWRAP>∣</TD>
83
<TD ALIGN=left NOWRAP> <FONT COLOR=maroon><TT><a href="#typexpr"><font color=maroon><I>typexpr</I></font></a></TT> <FONT COLOR=blue><TT>#</TT></FONT> <TT><a href="manual011.html#class-path"><font color=maroon><I>class-path</I></font></a></TT></FONT></TD>
85
<TR><TD ALIGN=right NOWRAP> </TD>
86
<TD ALIGN=right NOWRAP>∣</TD>
87
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>(</TT></FONT> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT> { <FONT COLOR=blue><TT>,</TT></FONT> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT> } ) <FONT COLOR=blue><TT>#</TT></FONT> <FONT COLOR=maroon><I><a href="manual011.html#class-path"><font color=maroon><TT>class-path</TT></font></a></I></FONT></TD>
89
<TR><TD ALIGN=right NOWRAP>
90
<A NAME="poly-typexpr"></A>
91
<FONT COLOR=maroon><I><TT>poly-typexpr</TT></I></FONT></TD>
92
<TD ALIGN=right NOWRAP>::=</TD>
93
<TD ALIGN=left NOWRAP>
94
<FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT></TD>
96
<TR><TD ALIGN=right NOWRAP> </TD>
97
<TD ALIGN=right NOWRAP>∣</TD>
98
<TD ALIGN=left NOWRAP> { <FONT COLOR=blue><TT>'</TT></FONT> <FONT COLOR=maroon><I><a href="manual009.html#ident"><font color=maroon><TT>ident</TT></font></a></I></FONT> }<SUP>+</SUP> <FONT COLOR=blue><TT>.</TT></FONT> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT></TD>
100
<TR><TD ALIGN=right NOWRAP>
101
<A NAME="method-type"></A>
102
<FONT COLOR=maroon><I><TT>method-type</TT></I></FONT></TD>
103
<TD ALIGN=right NOWRAP>::=</TD>
104
<TD ALIGN=left NOWRAP>
105
<FONT COLOR=maroon><TT><a href="manual011.html#method-name"><font color=maroon><I>method-name</I></font></a></TT> <FONT COLOR=blue><TT>:</TT></FONT> <TT><a href="#poly-typexpr"><font color=maroon><I>poly-typexpr</I></font></a></TT></FONT></TD>
106
</TR></TABLE></DIV><BR>
108
The table below shows the relative precedences and associativity of
16
<H2 CLASS="section"><A NAME="htoc63">6.4</A>��Type expressions</H2><P><A NAME="@manual.kwd2"></A></P><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
17
<I><A NAME="typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
18
<FONT COLOR=blue><TT>'</TT></FONT>�<I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I>
20
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>_</TT></FONT>�
22
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>(</TT></FONT>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�<FONT COLOR=blue><TT>)</TT></FONT>
24
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�[[<FONT COLOR=blue><TT>?</TT></FONT>]<I><A HREF="manual011.html#label-name"><FONT COLOR=maroon>label-name</FONT></A></I><FONT COLOR=blue><TT>:</TT></FONT>]��<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�<FONT COLOR=blue><TT>-></TT></FONT>��<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>
26
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>��{�<FONT COLOR=blue><TT>*</TT></FONT>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�}<SUP>+</SUP>
28
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<I><A HREF="manual011.html#typeconstr"><FONT COLOR=maroon>typeconstr</FONT></A></I>
30
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>��<I><A HREF="manual011.html#typeconstr"><FONT COLOR=maroon>typeconstr</FONT></A></I>
32
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>(</TT></FONT>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>��{�<FONT COLOR=blue><TT>,</TT></FONT>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�}�<FONT COLOR=blue><TT>)</TT></FONT>��<I><A HREF="manual011.html#typeconstr"><FONT COLOR=maroon>typeconstr</FONT></A></I>
34
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�<FONT COLOR=blue><TT>as</TT></FONT>�<FONT COLOR=blue><TT>'</TT></FONT>��<I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I>
36
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<I><A HREF="#variant-type"><FONT COLOR=maroon>variant-type</FONT></A></I>
38
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT><</TT></FONT>�[<FONT COLOR=blue><TT>..</TT></FONT>]�<FONT COLOR=blue><TT>></TT></FONT>
40
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT><</TT></FONT>�<I><A HREF="#method-type"><FONT COLOR=maroon>method-type</FONT></A></I>��{�<FONT COLOR=blue><TT>;</TT></FONT>�<I><A HREF="#method-type"><FONT COLOR=maroon>method-type</FONT></A></I>�}��[<FONT COLOR=blue><TT>;</TT></FONT>�<FONT COLOR=blue><TT>..</TT></FONT>]�<FONT COLOR=blue><TT>></TT></FONT>
42
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>#</TT></FONT>�<I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I>
44
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�<FONT COLOR=blue><TT>#</TT></FONT>��<I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I>
46
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>(</TT></FONT>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>��{�<FONT COLOR=blue><TT>,</TT></FONT>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�}�)�<FONT COLOR=blue><TT>#</TT></FONT>��<I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I>
48
<TR><TD ALIGN=right NOWRAP> </TD></TR>
49
<TR><TD ALIGN=right NOWRAP>
50
<I><A NAME="poly-typexpr"><FONT COLOR=maroon>poly-typexpr</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
51
<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>
53
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�{�<FONT COLOR=blue><TT>'</TT></FONT>�<I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I>�}<SUP>+</SUP>�<FONT COLOR=blue><TT>.</TT></FONT>��<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>
55
<TR><TD ALIGN=right NOWRAP> </TD></TR>
56
<TR><TD ALIGN=right NOWRAP>
57
<I><A NAME="method-type"><FONT COLOR=maroon>method-type</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
58
<I><A HREF="manual011.html#method-name"><FONT COLOR=maroon>method-name</FONT></A></I>�<FONT COLOR=blue><TT>:</TT></FONT>��<I><A HREF="#poly-typexpr"><FONT COLOR=maroon>poly-typexpr</FONT></A></I></TD></TR>
60
</TABLE><P>The table below shows the relative precedences and associativity of
109
61
operators and non-closed type constructions. The constructions with
110
62
higher precedences come first.
111
63
<A NAME="@manual.kwd3"></A>
114
<DIV CLASS="center"><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="80%">
115
<TR><TD ALIGN=center NOWRAP><B>Operator</B></TD>
116
<TD ALIGN=center NOWRAP><B>Associativity</B></TD>
64
</P><DIV CLASS="center"><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="80%"><TR><TD ALIGN=center NOWRAP><B>Operator</B></TD><TD ALIGN=center NOWRAP><B>Associativity</B></TD></TR>
118
65
<TR><TD ALIGN=left NOWRAP>
119
Type constructor application</TD>
120
<TD ALIGN=left NOWRAP>–</TD>
122
<TR><TD ALIGN=left NOWRAP><TT>*</TT></TD>
123
<TD ALIGN=left NOWRAP>–</TD>
125
<TR><TD ALIGN=left NOWRAP><TT>-></TT></TD>
126
<TD ALIGN=left NOWRAP>right</TD>
128
<TR><TD ALIGN=left NOWRAP><TT>as</TT></TD>
129
<TD ALIGN=left NOWRAP>–</TD>
130
</TR></TABLE></DIV><BR>
132
Type expressions denote types in definitions of data types as well as
133
in type constraints over patterns and expressions.<BR>
136
<H4 CLASS="subsubsection">Type variables</H4>
137
The type expression <FONT COLOR=blue><TT>'</TT></FONT> <FONT COLOR=maroon><I><TT>ident</TT></I></FONT> stands for the type variable named
138
<FONT COLOR=maroon><I><TT>ident</TT></I></FONT>. The type expression <FONT COLOR=blue><TT>_</TT></FONT> stands for an anonymous type variable.
66
Type constructor application</TD><TD ALIGN=left NOWRAP>–</TD></TR>
67
<TR><TD ALIGN=left NOWRAP><TT>*</TT></TD><TD ALIGN=left NOWRAP>–</TD></TR>
68
<TR><TD ALIGN=left NOWRAP><TT>-></TT></TD><TD ALIGN=left NOWRAP>right</TD></TR>
69
<TR><TD ALIGN=left NOWRAP><TT>as</TT></TD><TD ALIGN=left NOWRAP>–</TD></TR>
70
</TABLE></DIV><P>Type expressions denote types in definitions of data types as well as
71
in type constraints over patterns and expressions.</P><H4 CLASS="subsubsection">Type variables</H4><P>The type expression <FONT COLOR=blue><TT>'</TT></FONT> <I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I> stands for the type variable named
72
<I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I>. The type expression <FONT COLOR=blue><TT>_</TT></FONT> stands for an anonymous type variable.
139
73
In data type definitions, type variables are names for the
140
74
data type parameters. In type constraints, they represent unspecified
141
75
types that can be instantiated by any type to satisfy the type
142
76
constraint. In general the scope of a named type variable is the
143
77
whole enclosing definition; and they can only be generalized when leaving
144
78
this scope. Anonymous variables have no such restriction.
145
<div style="background-color:yellow; color:red; border-style:none; border-width:0.5pt">
146
79
In the following cases, the scope of named type variables is
147
80
restricted to the type expression where they appear: 1) for universal
148
81
(explicitly polymorphic) type variables; 2) for type variables that
149
82
only appear in public method specifications (as those variables will
150
be made universal, as described in section <A HREF="manual017.html#sec-methspec">6.9.1</A>);
83
be made universal, as described in section�<A HREF="manual017.html#sec-methspec">6.9.1</A>);
151
84
3) for variables used as aliases, when the type they are aliased to
152
85
would be invalid in the scope of the enclosing definition (<I>i.e.</I>
153
86
when it contains free universal type variables, or locally
158
<H4 CLASS="subsubsection">Parenthesized types</H4>
159
The type expression <FONT COLOR=blue><TT>(</TT> <FONT COLOR=maroon><TT><I>typexpr</I></TT></FONT> <TT>)</TT></FONT> denotes the same type as
160
<FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT>.<BR>
163
<H4 CLASS="subsubsection">Function types</H4>
164
The type expression <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>1</SUB> <FONT COLOR=blue><TT>-></TT></FONT> <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>2</SUB> denotes the type of
165
functions mapping arguments of type <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>1</SUB> to results of type
166
<FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>2</SUB>.<BR>
168
<FONT COLOR=maroon><TT><I>label-name</I></TT> <FONT COLOR=blue><TT>:</TT></FONT> <TT><I>typexpr</I></TT></FONT><SUB>1</SUB> <FONT COLOR=blue><TT>-></TT></FONT> <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>2</SUB> denotes the same function type, but
169
the argument is labeled <FONT COLOR=maroon><I><TT>label</TT></I></FONT>.<BR>
171
<FONT COLOR=maroon><I><TT>optlabel</TT> <TT>typexpr</TT></I></FONT><SUB>1</SUB> <FONT COLOR=blue><TT>-></TT></FONT> <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>2</SUB> denotes the type of functions
172
mapping an optional labeled argument of type <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>1</SUB> to results of
173
type <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>2</SUB>. That is, the physical type of the function will be
174
<FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>1</SUB> <FONT COLOR=blue><TT>option</TT> <TT>-></TT></FONT> <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>2</SUB>.<BR>
177
<H4 CLASS="subsubsection">Tuple types</H4>
178
The type expression <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>1</SUB> <FONT COLOR=blue><TT>*</TT></FONT> … <FONT COLOR=blue><TT>*</TT></FONT> <I><FONT COLOR=maroon><TT>typexpr</TT></FONT><SUB>n</SUB></I>
179
denotes the type of tuples whose elements belong to types <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>1</SUB>,
180
… <I><FONT COLOR=maroon><TT>typexpr</TT></FONT><SUB>n</SUB></I> respectively.<BR>
183
<H4 CLASS="subsubsection">Constructed types</H4>
184
Type constructors with no parameter, as in <FONT COLOR=maroon><I><TT>typeconstr</TT></I></FONT>, are type
187
The type expression <FONT COLOR=maroon><I><TT>typexpr</TT> <TT>typeconstr</TT></I></FONT>, where <FONT COLOR=maroon><I><TT>typeconstr</TT></I></FONT> is a type
87
defined types.)</P><H4 CLASS="subsubsection">Parenthesized types</H4><P>The type expression <FONT COLOR=blue><TT>(</TT></FONT> <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I> <FONT COLOR=blue><TT>)</TT></FONT> denotes the same type as
88
<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>.</P><H4 CLASS="subsubsection">Function types</H4><P>The type expression <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB> <FONT COLOR=blue><TT>-></TT></FONT> �<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>2</SUB> denotes the type of
89
functions mapping arguments of type <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB> to results of type
90
<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>2</SUB>.</P><P><I><A HREF="manual011.html#label-name"><FONT COLOR=maroon>label-name</FONT></A></I> <FONT COLOR=blue><TT>:</TT></FONT> �<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB> <FONT COLOR=blue><TT>-></TT></FONT> �<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>2</SUB> denotes the same function type, but
91
the argument is labeled <I><A HREF="lex.html#label"><FONT COLOR=maroon>label</FONT></A></I>.</P><P><I><A HREF="lex.html#optlabel"><FONT COLOR=maroon>optlabel</FONT></A></I> �<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB> <FONT COLOR=blue><TT>-></TT></FONT> �<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>2</SUB> denotes the type of functions
92
mapping an optional labeled argument of type <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB> to results of
93
type <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>2</SUB>. That is, the physical type of the function will be
94
<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB> <FONT COLOR=blue><TT>option</TT> <TT>-></TT></FONT> �<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>2</SUB>.</P><H4 CLASS="subsubsection">Tuple types</H4><P>The type expression <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB> <FONT COLOR=blue><TT>*</TT></FONT> … <FONT COLOR=blue><TT>*</TT></FONT> �<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A><SUB>n</SUB></I>
95
denotes the type of tuples whose elements belong to types <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB>,
96
… �<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A><SUB>n</SUB></I> respectively.</P><H4 CLASS="subsubsection">Constructed types</H4><P>Type constructors with no parameter, as in <I><A HREF="manual011.html#typeconstr"><FONT COLOR=maroon>typeconstr</FONT></A></I>, are type
97
expressions.</P><P>The type expression <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I> �<I><A HREF="manual011.html#typeconstr"><FONT COLOR=maroon>typeconstr</FONT></A></I>, where <I><A HREF="manual011.html#typeconstr"><FONT COLOR=maroon>typeconstr</FONT></A></I> is a type
188
98
constructor with one parameter, denotes the application of the unary type
189
constructor <FONT COLOR=maroon><I><TT>typeconstr</TT></I></FONT> to the type <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT>.<BR>
191
The type expression (<FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>1</SUB>,…, <I><FONT COLOR=maroon><TT>typexpr</TT></FONT><SUB>n</SUB></I>) <FONT COLOR=maroon><I><TT>typeconstr</TT></I></FONT>, where
192
<FONT COLOR=maroon><I><TT>typeconstr</TT></I></FONT> is a type constructor with <I>n</I> parameters, denotes the
193
application of the <I>n</I>-ary type constructor <FONT COLOR=maroon><I><TT>typeconstr</TT></I></FONT> to the types
194
<FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>1</SUB> through <I><FONT COLOR=maroon><TT>typexpr</TT></FONT><SUB>n</SUB></I>.<BR>
197
<H4 CLASS="subsubsection">Aliased and recursive types</H4>
198
<A NAME="@manual.kwd4"></A>
199
The type expression <FONT COLOR=maroon><TT><I>typexpr</I></TT> <FONT COLOR=blue><TT>as</TT> <TT>'</TT></FONT> <TT><I>ident</I></TT></FONT> denotes the same type as
200
<FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT>, and also binds the type variable <FONT COLOR=maroon><I><TT>ident</TT></I></FONT> to type <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT> both
201
in <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT> and in other
203
<div style="background-color:yellow; color:red; border-style:none; border-width:0.5pt">
204
In general the scope of an alias is
99
constructor <I><A HREF="manual011.html#typeconstr"><FONT COLOR=maroon>typeconstr</FONT></A></I> to the type <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>.</P><P>The type expression (<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB>,…,�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A><SUB>n</SUB></I>) �<I><A HREF="manual011.html#typeconstr"><FONT COLOR=maroon>typeconstr</FONT></A></I>, where
100
<I><A HREF="manual011.html#typeconstr"><FONT COLOR=maroon>typeconstr</FONT></A></I> is a type constructor with <I>n</I> parameters, denotes the
101
application of the <I>n</I>-ary type constructor <I><A HREF="manual011.html#typeconstr"><FONT COLOR=maroon>typeconstr</FONT></A></I> to the types
102
<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I><SUB>1</SUB> through <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A><SUB>n</SUB></I>.</P><H4 CLASS="subsubsection">Aliased and recursive types</H4><P><A NAME="@manual.kwd4"></A></P><P>The type expression <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I> <FONT COLOR=blue><TT>as</TT> <TT>'</TT></FONT> �<I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I> denotes the same type as
103
<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>, and also binds the type variable <I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I> to type <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I> both
104
in <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I> and in other types. In general the scope of an alias is
205
105
the same as for a named type variable, and covers the whole enclosing
209
<FONT COLOR=maroon><I><TT>ident</TT></I></FONT> actually occurs in <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT>, a recursive type is created. Recursive
106
definition. If the type variable
107
<I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I> actually occurs in <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>, a recursive type is created. Recursive
210
108
types for which there exists a recursive path that does not contain
211
109
an object or variant type constructor are rejected, except when the
212
<TT>-rectypes</TT> mode is selected.<BR>
214
If <FONT COLOR=blue><TT>'</TT></FONT> <FONT COLOR=maroon><I><TT>ident</TT></I></FONT> denotes an explicit polymorphic variable, and <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT>
215
denotes either an object or variant type, the row variable of <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT>
216
is captured by <FONT COLOR=blue><TT>'</TT></FONT> <FONT COLOR=maroon><I><TT>ident</TT></I></FONT>, and quantified upon.<BR>
219
<H4 CLASS="subsubsection"><A NAME="xhtoc10"></A>Variant types</H4><BR>
221
<DIV CLASS="center"><TABLE CELLSPACING=2 CELLPADDING=0>
222
<TR><TD ALIGN=right NOWRAP>
223
<A NAME="variant-type"></A>
224
<FONT COLOR=maroon><I><TT>variant-type</TT></I></FONT></TD>
225
<TD ALIGN=right NOWRAP>::=</TD>
226
<TD ALIGN=left NOWRAP>
227
<FONT COLOR=blue><TT>[</TT></FONT> [ <FONT COLOR=blue><TT>|</TT></FONT> ] <FONT COLOR=maroon><I><a href="#tag-spec"><font color=maroon><TT>tag-spec</TT></font></a></I></FONT> { <FONT COLOR=blue><TT>|</TT></FONT> <FONT COLOR=maroon><I><a href="#tag-spec"><font color=maroon><TT>tag-spec</TT></font></a></I></FONT> } <FONT COLOR=blue><TT>]</TT></FONT></TD>
229
<TR><TD ALIGN=right NOWRAP> </TD>
230
<TD ALIGN=right NOWRAP>∣</TD>
231
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>[></TT></FONT> [ <FONT COLOR=maroon><I><a href="#tag-spec"><font color=maroon><TT>tag-spec</TT></font></a></I></FONT> ] { <FONT COLOR=blue><TT>|</TT></FONT> <FONT COLOR=maroon><I><a href="#tag-spec"><font color=maroon><TT>tag-spec</TT></font></a></I></FONT> } <FONT COLOR=blue><TT>]</TT></FONT></TD>
233
<TR><TD ALIGN=right NOWRAP> </TD>
234
<TD ALIGN=right NOWRAP>∣</TD>
235
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>[<</TT></FONT> [ <FONT COLOR=blue><TT>|</TT></FONT> ] <FONT COLOR=maroon><I><a href="#tag-spec-full"><font color=maroon><TT>tag-spec-full</TT></font></a></I></FONT> { <FONT COLOR=blue><TT>|</TT></FONT> <FONT COLOR=maroon><I><a href="#tag-spec-full"><font color=maroon><TT>tag-spec-full</TT></font></a></I></FONT> } [ <FONT COLOR=blue><TT>></TT></FONT> { <TT><FONT COLOR=blue>`</FONT><FONT COLOR=maroon><a href="manual011.html#tag-name"><font color=maroon><I>tag-name</I></font></a></FONT></TT> }<SUP>+</SUP> ] <FONT COLOR=blue><TT>]</TT></FONT></TD>
237
<TR><TD ALIGN=right NOWRAP>
238
<A NAME="tag-spec"></A>
239
<FONT COLOR=maroon><I><TT>tag-spec</TT></I></FONT></TD>
240
<TD ALIGN=right NOWRAP>::=</TD>
241
<TD ALIGN=left NOWRAP>
242
<TT><FONT COLOR=blue>`</FONT><FONT COLOR=maroon><a href="manual011.html#tag-name"><font color=maroon><I>tag-name</I></font></a></FONT></TT> [ <FONT COLOR=blue><TT>of</TT></FONT> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT> ]</TD>
244
<TR><TD ALIGN=right NOWRAP> </TD>
245
<TD ALIGN=right NOWRAP>∣</TD>
246
<TD ALIGN=left NOWRAP> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT></TD>
248
<TR><TD ALIGN=right NOWRAP>
249
<A NAME="tag-spec-full"></A>
250
<FONT COLOR=maroon><I><TT>tag-spec-full</TT></I></FONT></TD>
251
<TD ALIGN=right NOWRAP>::=</TD>
252
<TD ALIGN=left NOWRAP>
253
<TT><FONT COLOR=blue>`</FONT><FONT COLOR=maroon><a href="manual011.html#tag-name"><font color=maroon><I>tag-name</I></font></a></FONT></TT> [ <FONT COLOR=blue><TT>of</TT></FONT> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT> ] { <FONT COLOR=blue><TT>&</TT></FONT> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT> }</TD>
255
<TR><TD ALIGN=right NOWRAP> </TD>
256
<TD ALIGN=right NOWRAP>∣</TD>
257
<TD ALIGN=left NOWRAP> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT></TD>
258
</TR></TABLE></DIV><BR>
260
Variant types describe the values a polymorphic variant may take.<BR>
262
The first case is an exact variant type: all possible tags are
110
<TT>-rectypes</TT> mode is selected.</P><P>If <FONT COLOR=blue><TT>'</TT></FONT> <I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I> denotes an explicit polymorphic variable, and <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>
111
denotes either an object or variant type, the row variable of <I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>
112
is captured by <FONT COLOR=blue><TT>'</TT></FONT> <I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I>, and quantified upon.</P><H4 CLASS="subsubsection">Variant types</H4><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
113
<I><A NAME="variant-type"><FONT COLOR=maroon>variant-type</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
114
<FONT COLOR=blue><TT>[</TT></FONT>�[�<FONT COLOR=blue><TT>|</TT></FONT>�]�<I><A HREF="#tag-spec"><FONT COLOR=maroon>tag-spec</FONT></A></I>��{�<FONT COLOR=blue><TT>|</TT></FONT>�<I><A HREF="#tag-spec"><FONT COLOR=maroon>tag-spec</FONT></A></I>�}�<FONT COLOR=blue><TT>]</TT></FONT>
116
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>[></TT></FONT>�[�<I><A HREF="#tag-spec"><FONT COLOR=maroon>tag-spec</FONT></A></I>�]��{�<FONT COLOR=blue><TT>|</TT></FONT>�<I><A HREF="#tag-spec"><FONT COLOR=maroon>tag-spec</FONT></A></I>�}�<FONT COLOR=blue><TT>]</TT></FONT>
118
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>[<</TT></FONT>�[�<FONT COLOR=blue><TT>|</TT></FONT>�]�<I><A HREF="#tag-spec-full"><FONT COLOR=maroon>tag-spec-full</FONT></A></I>��{�<FONT COLOR=blue><TT>|</TT></FONT>�<I><A HREF="#tag-spec-full"><FONT COLOR=maroon>tag-spec-full</FONT></A></I>�}��[�<FONT COLOR=blue><TT>></TT></FONT>�{�<FONT COLOR=blue><TT>`</TT></FONT><I><A HREF="manual011.html#tag-name"><FONT COLOR=maroon>tag-name</FONT></A></I>�}<SUP>+</SUP>�]�<FONT COLOR=blue><TT>]</TT></FONT>
120
<TR><TD ALIGN=right NOWRAP> </TD></TR>
121
<TR><TD ALIGN=right NOWRAP>
122
<I><A NAME="tag-spec"><FONT COLOR=maroon>tag-spec</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
123
<FONT COLOR=blue><TT>`</TT></FONT><I><A HREF="manual011.html#tag-name"><FONT COLOR=maroon>tag-name</FONT></A></I>��[�<FONT COLOR=blue><TT>of</TT></FONT>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�]
125
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>
127
<TR><TD ALIGN=right NOWRAP> </TD></TR>
128
<TR><TD ALIGN=right NOWRAP>
129
<I><A NAME="tag-spec-full"><FONT COLOR=maroon>tag-spec-full</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
130
<FONT COLOR=blue><TT>`</TT></FONT><I><A HREF="manual011.html#tag-name"><FONT COLOR=maroon>tag-name</FONT></A></I>��[�<FONT COLOR=blue><TT>of</TT></FONT>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�]��{�<FONT COLOR=blue><TT>&</TT></FONT>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�}
132
<TR><TD ALIGN=right NOWRAP> </TD><TD ALIGN=center NOWRAP>∣</TD><TD ALIGN=left NOWRAP>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>
134
<TR><TD ALIGN=right NOWRAP> </TD></TR>
136
</TABLE><P>Variant types describe the values a polymorphic variant may take.</P><P>The first case is an exact variant type: all possible tags are
263
137
known, with their associated types, and they can all be present.
264
Its structure is fully known.<BR>
266
The second case is an open variant type, describing a polymorphic
138
Its structure is fully known.</P><P>The second case is an open variant type, describing a polymorphic
267
139
variant value: it gives the list of all tags the value could take,
268
140
with their associated types. This type is still compatible with a
269
141
variant type containing more tags. A special case is the unknown
270
142
type, which does not define any tag, and is compatible with any
273
The third case is a closed variant type. It gives information about
143
variant type.</P><P>The third case is a closed variant type. It gives information about
274
144
all the possible tags and their associated types, and which tags are
275
145
known to potentially appear in values. The above exact variant type is
276
146
just an abbreviation for a closed variant type where all possible tags
277
are also potentially present.<BR>
279
In all three cases, tags may be either specified directly in the
280
<I>`tag-name [...]</I> form, or indirectly through a type
147
are also potentially present.</P><P>In all three cases, tags may be either specified directly in the
148
<I>`tag-name </I>[…] form, or indirectly through a type
281
149
expression. In this last case, the type expression must expand to an
282
150
exact variant type, whose tag specifications are inserted in its
285
Full specification of variant tags are only used for non-exact closed
151
place.</P><P>Full specification of variant tags are only used for non-exact closed
286
152
types. They can be understood as a conjunctive type for the argument:
287
153
it is intended to have all the types enumerated in the
290
Such conjunctive constraints may be unsatisfiable. In such a case the
154
specification.</P><P>Such conjunctive constraints may be unsatisfiable. In such a case the
291
155
corresponding tag may not be used in a value of this type. This
292
156
does not mean that the whole type is not valid: one can still use
293
other available tags.<BR>
296
<H4 CLASS="subsubsection">Object types</H4>
298
<FONT COLOR=blue><TT><</TT></FONT> <FONT COLOR=maroon><I><TT>method-type</TT></I></FONT> { <FONT COLOR=blue><TT>;</TT></FONT> <FONT COLOR=maroon><I><TT>method-type</TT></I></FONT> } <FONT COLOR=blue><TT>></TT></FONT>
299
is a record of method types.<BR>
301
Each method may have an explicit polymorphic type: { <FONT COLOR=blue><TT>'</TT></FONT> <FONT COLOR=maroon><I><TT>ident</TT></I></FONT> }<SUP>+</SUP>
302
<FONT COLOR=blue><TT>.</TT></FONT> <FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT>. Explicit polymorphic variables have a local scope, and
157
other available tags.</P><H4 CLASS="subsubsection">Object types</H4><P>An object type
158
<FONT COLOR=blue><TT><</TT></FONT> <I><A HREF="#method-type"><FONT COLOR=maroon>method-type</FONT></A></I> �{ <FONT COLOR=blue><TT>;</TT></FONT> <I><A HREF="#method-type"><FONT COLOR=maroon>method-type</FONT></A></I> } <FONT COLOR=blue><TT>></TT></FONT>
159
is a record of method types.</P><P>Each method may have an explicit polymorphic type: { <FONT COLOR=blue><TT>'</TT></FONT> <I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I> }<SUP>+</SUP>
160
<FONT COLOR=blue><TT>.</TT></FONT> �<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>. Explicit polymorphic variables have a local scope, and
303
161
an explicit polymorphic type can only be unified to an
304
equivalent one, with polymorphic variables at the same positions.<BR>
306
The type <FONT COLOR=blue><TT><</TT></FONT> <FONT COLOR=maroon><I><TT>method-type</TT></I></FONT> { <FONT COLOR=blue><TT>;</TT></FONT> <FONT COLOR=maroon><I><TT>method-type</TT></I></FONT> } <FONT COLOR=blue><TT>;</TT> <TT>..</TT> <TT>></TT></FONT> is the
162
equivalent one, with polymorphic variables at the same positions.</P><P>The type <FONT COLOR=blue><TT><</TT></FONT> <I><A HREF="#method-type"><FONT COLOR=maroon>method-type</FONT></A></I> �{ <FONT COLOR=blue><TT>;</TT></FONT> <I><A HREF="#method-type"><FONT COLOR=maroon>method-type</FONT></A></I> } <FONT COLOR=blue><TT>;</TT> <TT>..</TT> <TT>></TT></FONT> is the
307
163
type of an object with methods and their associated types are described by
308
<FONT COLOR=maroon><I><TT>method-type</TT></I></FONT><SUB>1</SUB>, …, <I><FONT COLOR=maroon><TT>method-type</TT></FONT><SUB>n</SUB></I>, and possibly some other
164
<I><A HREF="#method-type"><FONT COLOR=maroon>method-type</FONT></A></I><SUB>1</SUB>, …, �<I><A HREF="#method-type"><FONT COLOR=maroon>method-type</FONT></A><SUB>n</SUB></I>, and possibly some other
309
165
methods represented by the ellipsis. This ellipsis actually is
310
166
a special kind of type variable (also called <EM>row variable</EM> in the
311
literature) that stands for any number of extra method types.<BR>
314
<H4 CLASS="subsubsection">#-types</H4>
315
<A NAME="s:sharp-types"></A>
316
The type <FONT COLOR=blue><TT>#</TT></FONT> <FONT COLOR=maroon><I><TT>class-path</TT></I></FONT> is a special kind of abbreviation. This
167
literature) that stands for any number of extra method types.</P><H4 CLASS="subsubsection">#-types</H4><P>
168
<A NAME="s:sharp-types"></A></P><P>The type <FONT COLOR=blue><TT>#</TT></FONT> <I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I> is a special kind of abbreviation. This
317
169
abbreviation unifies with the type of any object belonging to a subclass
318
of class <FONT COLOR=maroon><I><TT>class-path</TT></I></FONT>.
170
of class <I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I>.
319
171
It is handled in a special way as it usually hides a type variable (an
320
172
ellipsis, representing the methods that may be added in a subclass).
321
173
In particular, it vanishes when the ellipsis gets instantiated.
322
Each type expression <FONT COLOR=blue><TT>#</TT></FONT> <FONT COLOR=maroon><I><TT>class-path</TT></I></FONT> defines a new type variable, so
323
type <FONT COLOR=blue><TT>#</TT></FONT> <FONT COLOR=maroon><TT><I>class-path</I></TT> <FONT COLOR=blue><TT>-></TT> <TT>#</TT></FONT> <TT><I>class-path</I></TT></FONT> is usually not the same as
324
type (<FONT COLOR=blue><TT>#</TT></FONT> <FONT COLOR=maroon><TT><I>class-path</I></TT> <FONT COLOR=blue><TT>as</TT> <TT>'</TT></FONT> <TT><I>ident</I></TT></FONT>) <FONT COLOR=blue><TT>-></TT> <TT>'</TT></FONT> <FONT COLOR=maroon><I><TT>ident</TT></I></FONT>.
327
Use of #-types to abbreviate variant types is deprecated.
174
Each type expression <FONT COLOR=blue><TT>#</TT></FONT> <I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I> defines a new type variable, so
175
type <FONT COLOR=blue><TT>#</TT></FONT> <I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I> <FONT COLOR=blue><TT>-></TT> <TT>#</TT></FONT> �<I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I> is usually not the same as
176
type (<FONT COLOR=blue><TT>#</TT></FONT> <I><A HREF="manual011.html#class-path"><FONT COLOR=maroon>class-path</FONT></A></I> <FONT COLOR=blue><TT>as</TT> <TT>'</TT></FONT> �<I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I>) <FONT COLOR=blue><TT>-></TT> <TT>'</TT></FONT> �<I><A HREF="lex.html#ident"><FONT COLOR=maroon>ident</FONT></A></I>.
177
</P><P>Use of #-types to abbreviate variant types is deprecated.
328
178
If <TT>t</TT> is an exact variant type then <TT>#t</TT> translates to <TT>[< t]</TT>,
329
and <FONT COLOR=blue><TT>#t[></TT> <TT>`tag</TT></FONT><SUB>1</SUB> ...<FONT COLOR=blue><TT>`tag</TT></FONT><I><SUB>k</SUB></I><FONT COLOR=blue><TT>]</TT></FONT> translates to
330
<FONT COLOR=blue><TT>[<</TT> <TT>t</TT> <TT>></TT> <TT>`tag</TT></FONT><SUB>1</SUB> ...<FONT COLOR=blue><TT>`tag</TT></FONT><I><SUB>k</SUB></I><FONT COLOR=blue><TT>]</TT></FONT><BR>
333
<H4 CLASS="subsubsection">Variant and record types</H4>
334
There are no type expressions describing (defined) variant types nor
179
and <FONT COLOR=blue><TT>#t[></TT> <TT>`tag</TT></FONT><SUB>1</SUB> …<FONT COLOR=blue><TT>`tag</TT></FONT><I><SUB>k</SUB></I><FONT COLOR=blue><TT>]</TT></FONT> translates to
180
<FONT COLOR=blue><TT>[<</TT> <TT>t</TT> <TT>></TT> <TT>`tag</TT></FONT><SUB>1</SUB> …<FONT COLOR=blue><TT>`tag</TT></FONT><I><SUB>k</SUB></I><FONT COLOR=blue><TT>]</TT></FONT></P><H4 CLASS="subsubsection">Variant and record types</H4><P>There are no type expressions describing (defined) variant types nor
335
181
record types, since those are always named, i.e. defined before use
336
182
and referred to by name. Type definitions are described in
337
section <A HREF="manual016.html#s:type-defs">6.8.1</A>.
183
section�<A HREF="manual016.html#s:type-defs">6.8.1</A>.
342
<A HREF="manual011.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
343
<A HREF="manual008.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
344
<A HREF="manual013.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
186
<A HREF="manual011.html"><IMG SRC="previous_motif.gif" ALT="Previous"></A>
187
<A HREF="manual008.html"><IMG SRC="contents_motif.gif" ALT="Up"></A>
188
<A HREF="manual013.html"><IMG SRC="next_motif.gif" ALT="Next"></A>