~ubuntu-branches/ubuntu/hardy/ocaml-doc/hardy

« back to all changes in this revision

Viewing changes to ocaml.html/manual012.html

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2007-09-08 01:49:22 UTC
  • mfrom: (0.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070908014922-lvihyehz0ndq7suu
Tags: 3.10-1
* New upstream release.
* Removed camlp4 documentation since it is not up-to-date.
* Updated to standards version 3.7.2, no changes needed.
* Updated my email address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
<HTML>
4
4
<HEAD>
5
5
 
6
 
 
7
 
 
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">
11
 
<TITLE>
12
 
Type expressions
13
 
</TITLE>
 
9
<TITLE>Type expressions</TITLE>
14
10
</HEAD>
15
11
<BODY >
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>
19
15
<HR>
20
 
 
21
 
<H2 CLASS="section"><A NAME="htoc63">6.4</A>&nbsp;&nbsp;Type expressions</H2>
22
 
 
23
 
<A NAME="@manual.kwd2"></A><BR>
24
 
<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>
32
 
</TR>
33
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
34
 
<TD ALIGN=right NOWRAP>&#8739;</TD>
35
 
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>_</TT></FONT></TD>
36
 
</TR>
37
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
38
 
<TD ALIGN=right NOWRAP>&#8739;</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>
40
 
</TR>
41
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
42
 
<TD ALIGN=right NOWRAP>&#8739;</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>] &nbsp;<FONT COLOR=maroon><TT><a href="#typexpr"><font color=maroon><I>typexpr</I></font></a></TT> <FONT COLOR=blue><TT>-&gt;</TT></FONT> &nbsp;<TT><a href="#typexpr"><font color=maroon><I>typexpr</I></font></a></TT></FONT></TD>
44
 
</TR>
45
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
46
 
<TD ALIGN=right NOWRAP>&#8739;</TD>
47
 
<TD ALIGN=left NOWRAP> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT> &nbsp;{ <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>
48
 
</TR>
49
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
50
 
<TD ALIGN=right NOWRAP>&#8739;</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>
52
 
</TR>
53
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
54
 
<TD ALIGN=right NOWRAP>&#8739;</TD>
55
 
<TD ALIGN=left NOWRAP> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a> &nbsp;<a href="manual011.html#typeconstr"><font color=maroon><TT>typeconstr</TT></font></a></I></FONT></TD>
56
 
</TR>
57
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
58
 
<TD ALIGN=right NOWRAP>&#8739;</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> &nbsp;{ <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> &nbsp;<FONT COLOR=maroon><I><a href="manual011.html#typeconstr"><font color=maroon><TT>typeconstr</TT></font></a></I></FONT></TD>
60
 
</TR>
61
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
62
 
<TD ALIGN=right NOWRAP>&#8739;</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> &nbsp;<TT><a href="manual009.html#ident"><font color=maroon><I>ident</I></font></a></TT></FONT></TD>
64
 
</TR>
65
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
66
 
<TD ALIGN=right NOWRAP>&#8739;</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>
68
 
</TR>
69
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
70
 
<TD ALIGN=right NOWRAP>&#8739;</TD>
71
 
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>&lt;</TT></FONT> [<FONT COLOR=blue><TT>..</TT></FONT>] <FONT COLOR=blue><TT>&gt;</TT></FONT></TD>
72
 
</TR>
73
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
74
 
<TD ALIGN=right NOWRAP>&#8739;</TD>
75
 
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>&lt;</TT></FONT> <FONT COLOR=maroon><I><a href="#method-type"><font color=maroon><TT>method-type</TT></font></a></I></FONT> &nbsp;{ <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> } &nbsp;[<FONT COLOR=blue><TT>;</TT> <TT>..</TT></FONT>] <FONT COLOR=blue><TT>&gt;</TT></FONT></TD>
76
 
</TR>
77
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
78
 
<TD ALIGN=right NOWRAP>&#8739;</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>
80
 
</TR>
81
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
82
 
<TD ALIGN=right NOWRAP>&#8739;</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> &nbsp;<TT><a href="manual011.html#class-path"><font color=maroon><I>class-path</I></font></a></TT></FONT></TD>
84
 
</TR>
85
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
86
 
<TD ALIGN=right NOWRAP>&#8739;</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> &nbsp;{ <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> &nbsp;<FONT COLOR=maroon><I><a href="manual011.html#class-path"><font color=maroon><TT>class-path</TT></font></a></I></FONT></TD>
88
 
</TR>
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>
95
 
</TR>
96
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
97
 
<TD ALIGN=right NOWRAP>&#8739;</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> &nbsp;<FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT></TD>
99
 
</TR>
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> &nbsp;<TT><a href="#poly-typexpr"><font color=maroon><I>poly-typexpr</I></font></a></TT></FONT></TD>
106
 
</TR></TABLE></DIV><BR>
107
 
<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>
 
19
�</TD></TR>
 
20
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>_</TT></FONT>�
 
21
�</TD></TR>
 
22
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</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>
 
23
�</TD></TR>
 
24
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</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>-&gt;</TT></FONT>��<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>
 
25
�</TD></TR>
 
26
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</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>
 
27
�</TD></TR>
 
28
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�<I><A HREF="manual011.html#typeconstr"><FONT COLOR=maroon>typeconstr</FONT></A></I>
 
29
�</TD></TR>
 
30
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</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>
 
31
�</TD></TR>
 
32
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</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>
 
33
�</TD></TR>
 
34
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</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>
 
35
�</TD></TR>
 
36
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�<I><A HREF="#variant-type"><FONT COLOR=maroon>variant-type</FONT></A></I>
 
37
�</TD></TR>
 
38
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>&lt;</TT></FONT>�[<FONT COLOR=blue><TT>..</TT></FONT>]�<FONT COLOR=blue><TT>&gt;</TT></FONT>
 
39
�</TD></TR>
 
40
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>&lt;</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>&gt;</TT></FONT>
 
41
�</TD></TR>
 
42
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</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>
 
43
�</TD></TR>
 
44
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</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>
 
45
�</TD></TR>
 
46
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</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>
 
47
�</TD></TR>
 
48
<TR><TD ALIGN=right NOWRAP>&nbsp;</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>
 
52
�</TD></TR>
 
53
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</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>
 
54
�</TD></TR>
 
55
<TR><TD ALIGN=right NOWRAP>&nbsp;</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>
 
59
</TABLE></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>
112
 
<BR>
113
 
<BR>
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>
117
 
</TR>
 
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>&ndash;</TD>
121
 
</TR>
122
 
<TR><TD ALIGN=left NOWRAP><TT>*</TT></TD>
123
 
<TD ALIGN=left NOWRAP>&ndash;</TD>
124
 
</TR>
125
 
<TR><TD ALIGN=left NOWRAP><TT>-&gt;</TT></TD>
126
 
<TD ALIGN=left NOWRAP>right</TD>
127
 
</TR>
128
 
<TR><TD ALIGN=left NOWRAP><TT>as</TT></TD>
129
 
<TD ALIGN=left NOWRAP>&ndash;</TD>
130
 
</TR></TABLE></DIV><BR>
131
 
<BR>
132
 
Type expressions denote types in definitions of data types as well as
133
 
in type constraints over patterns and expressions.<BR>
134
 
<BR>
135
 
 
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>&#X2013;</TD></TR>
 
67
<TR><TD ALIGN=left NOWRAP><TT>*</TT></TD><TD ALIGN=left NOWRAP>&#X2013;</TD></TR>
 
68
<TR><TD ALIGN=left NOWRAP><TT>-&gt;</TT></TD><TD ALIGN=left NOWRAP>right</TD></TR>
 
69
<TR><TD ALIGN=left NOWRAP><TT>as</TT></TD><TD ALIGN=left NOWRAP>&#X2013;</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&nbsp;<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
154
 
defined types.)<BR>
155
 
</div>
156
 
<BR>
157
 
 
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>
161
 
<BR>
162
 
 
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>-&gt;</TT></FONT> &nbsp;<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>
167
 
<BR>
168
 
<FONT COLOR=maroon><TT><I>label-name</I></TT> <FONT COLOR=blue><TT>:</TT></FONT> &nbsp;<TT><I>typexpr</I></TT></FONT><SUB>1</SUB> <FONT COLOR=blue><TT>-&gt;</TT></FONT> &nbsp;<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>
170
 
<BR>
171
 
<FONT COLOR=maroon><I><TT>optlabel</TT> &nbsp;<TT>typexpr</TT></I></FONT><SUB>1</SUB> <FONT COLOR=blue><TT>-&gt;</TT></FONT> &nbsp;<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>-&gt;</TT></FONT> &nbsp;<FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>2</SUB>.<BR>
175
 
<BR>
176
 
 
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> &hellip; <FONT COLOR=blue><TT>*</TT></FONT> &nbsp;<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
 
&hellip; &nbsp;<I><FONT COLOR=maroon><TT>typexpr</TT></FONT><SUB>n</SUB></I> respectively.<BR>
181
 
<BR>
182
 
 
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
185
 
expressions.<BR>
186
 
<BR>
187
 
The type expression <FONT COLOR=maroon><I><TT>typexpr</TT> &nbsp;<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>-&gt;</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>-&gt;</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>-&gt;</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>-&gt;</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> &#X2026; <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
&#X2026; �<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>
190
 
<BR>
191
 
The type expression (<FONT COLOR=maroon><I><TT>typexpr</TT></I></FONT><SUB>1</SUB>,&hellip;,&nbsp;<I><FONT COLOR=maroon><TT>typexpr</TT></FONT><SUB>n</SUB></I>) &nbsp;<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>
195
 
<BR>
196
 
 
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> &nbsp;<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
202
 
types.
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>,&#X2026;,�<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
206
 
definition.
207
 
</div>
208
 
If the type variable
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>
213
 
<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>
217
 
<BR>
218
 
 
219
 
<H4 CLASS="subsubsection"><A NAME="xhtoc10"></A>Variant types</H4><BR>
220
 
<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> &nbsp;{ <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>
228
 
</TR>
229
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
230
 
<TD ALIGN=right NOWRAP>&#8739;</TD>
231
 
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>[&gt;</TT></FONT> [ <FONT COLOR=maroon><I><a href="#tag-spec"><font color=maroon><TT>tag-spec</TT></font></a></I></FONT> ] &nbsp;{ <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>
232
 
</TR>
233
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
234
 
<TD ALIGN=right NOWRAP>&#8739;</TD>
235
 
<TD ALIGN=left NOWRAP> <FONT COLOR=blue><TT>[&lt;</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> &nbsp;{ <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> } &nbsp;[ <FONT COLOR=blue><TT>&gt;</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>
236
 
</TR>
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> &nbsp;[ <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>
243
 
</TR>
244
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
245
 
<TD ALIGN=right NOWRAP>&#8739;</TD>
246
 
<TD ALIGN=left NOWRAP> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT></TD>
247
 
</TR>
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> &nbsp;[ <FONT COLOR=blue><TT>of</TT></FONT> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT> ] &nbsp;{ <FONT COLOR=blue><TT>&amp;</TT></FONT> <FONT COLOR=maroon><I><a href="#typexpr"><font color=maroon><TT>typexpr</TT></font></a></I></FONT> }</TD>
254
 
</TR>
255
 
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
256
 
<TD ALIGN=right NOWRAP>&#8739;</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>
259
 
<BR>
260
 
Variant types describe the values a polymorphic variant may take.<BR>
261
 
<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>
 
115
�</TD></TR>
 
116
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>[&gt;</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>
 
117
�</TD></TR>
 
118
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>[&lt;</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>&gt;</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>
 
119
�</TD></TR>
 
120
<TR><TD ALIGN=right NOWRAP>&nbsp;</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>�]
 
124
�</TD></TR>
 
125
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>
 
126
�</TD></TR>
 
127
<TR><TD ALIGN=right NOWRAP>&nbsp;</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>&amp;</TT></FONT>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>�}
 
131
�</TD></TR>
 
132
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�<I><A HREF="#typexpr"><FONT COLOR=maroon>typexpr</FONT></A></I>
 
133
�</TD></TR>
 
134
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD></TR>
 
135
</TABLE></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>
265
 
<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
271
 
variant type.<BR>
272
 
<BR>
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>
278
 
<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>[&#X2026;] 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
283
 
place.<BR>
284
 
<BR>
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
288
 
specification.<BR>
289
 
<BR>
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>
294
 
<BR>
295
 
 
296
 
<H4 CLASS="subsubsection">Object types</H4>
297
 
An object type
298
 
<FONT COLOR=blue><TT>&lt;</TT></FONT> <FONT COLOR=maroon><I><TT>method-type</TT></I></FONT> &nbsp;{ <FONT COLOR=blue><TT>;</TT></FONT> <FONT COLOR=maroon><I><TT>method-type</TT></I></FONT> } <FONT COLOR=blue><TT>&gt;</TT></FONT>
299
 
is a record of method types.<BR>
300
 
<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> &nbsp;<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>&lt;</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>&gt;</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>
305
 
<BR>
306
 
The type <FONT COLOR=blue><TT>&lt;</TT></FONT> <FONT COLOR=maroon><I><TT>method-type</TT></I></FONT> &nbsp;{ <FONT COLOR=blue><TT>;</TT></FONT> <FONT COLOR=maroon><I><TT>method-type</TT></I></FONT> } <FONT COLOR=blue><TT>;</TT> <TT>..</TT> <TT>&gt;</TT></FONT> is the
 
162
equivalent one, with polymorphic variables at the same positions.</P><P>The type <FONT COLOR=blue><TT>&lt;</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>&gt;</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>, &hellip;, &nbsp;<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>, &#X2026;, �<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>
312
 
<BR>
313
 
 
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>-&gt;</TT> <TT>#</TT></FONT> &nbsp;<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> &nbsp;<TT><I>ident</I></TT></FONT>) <FONT COLOR=blue><TT>-&gt;</TT> <TT>'</TT></FONT> &nbsp;<FONT COLOR=maroon><I><TT>ident</TT></I></FONT>.
325
 
<BR>
326
 
<BR>
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>-&gt;</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>-&gt;</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>[&lt; t]</TT>,
329
 
and <FONT COLOR=blue><TT>#t[&gt;</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>[&lt;</TT> <TT>t</TT> <TT>&gt;</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>
331
 
<BR>
332
 
 
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[&gt;</TT> <TT>`tag</TT></FONT><SUB>1</SUB> &#X2026;<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>[&lt;</TT> <TT>t</TT> <TT>&gt;</TT> <TT>`tag</TT></FONT><SUB>1</SUB> &#X2026;<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&nbsp;<A HREF="manual016.html#s:type-defs">6.8.1</A>.
 
183
section�<A HREF="manual016.html#s:type-defs">6.8.1</A>.
338
184
 
339
 
<BR>
340
 
<BR>
341
 
<HR>
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>
 
185
</P><HR>
 
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>
345
189
</BODY>
346
190
</HTML>