Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > 19bb6433bb07a8b16410504336791904 > files > 219

ocaml-doc-3.06-5mdk.ppc.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>

<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.06-7 of 2001-11-14">
<TITLE>
 Type expressions
</TITLE>
</HEAD>
<BODY TEXT=black BGCOLOR=white>
<A HREF="manual011.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual008.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="manual013.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#66ff66"><DIV ALIGN=center><TABLE>
<TR><TD><A NAME="htoc62"><B><FONT SIZE=5>6.4</FONT></B></A></TD>
<TD WIDTH="100%" ALIGN=center><B><FONT SIZE=5>Type expressions</FONT></B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
<BR>
<A NAME="@manual.kwd2"></A><BR>
<DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT></TD>
<TD ALIGN=right NOWRAP>::=</TD>
<TD ALIGN=left NOWRAP>
 <TT><FONT COLOR=blue>'</FONT></TT> <TT><I><FONT COLOR=maroon>ident</FONT></I></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>_</FONT></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> [[<TT><FONT COLOR=blue>?</FONT></TT>]<TT><I><FONT COLOR=maroon>ident</FONT></I></TT><TT><FONT COLOR=blue>:</FONT></TT>] &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> <TT><FONT COLOR=blue>-&gt;</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> &nbsp;{ <TT><FONT COLOR=blue>*</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> }<SUP><FONT SIZE=2>+</FONT></SUP></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>typeconstr</FONT></I></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> &nbsp;<TT><I><FONT COLOR=maroon>typeconstr</FONT></I></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> &nbsp;{ <TT><FONT COLOR=blue>,</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> } <TT><FONT COLOR=blue>)</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>typeconstr</FONT></I></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> <TT><FONT COLOR=blue>as</FONT></TT> <TT><FONT COLOR=blue>'</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>ident</FONT></I></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>[</FONT></TT> <TT><I><FONT COLOR=maroon>variant-type</FONT></I></TT> <TT><FONT COLOR=blue>]</FONT></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>&lt;</FONT></TT> [<TT><FONT COLOR=blue>..</FONT></TT>] <TT><FONT COLOR=blue>&gt;</FONT></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>&lt;</FONT></TT> <TT><I><FONT COLOR=maroon>method-type</FONT></I></TT> &nbsp;{ <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>method-type</FONT></I></TT> } &nbsp;[<TT><FONT COLOR=blue>;</FONT></TT> <TT><FONT COLOR=blue>..</FONT></TT>] <TT><FONT COLOR=blue>&gt;</FONT></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>#</FONT></TT> <TT><I><FONT COLOR=maroon>class-path</FONT></I></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> <TT><FONT COLOR=blue>#</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>class-path</FONT></I></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> &nbsp;{ <TT><FONT COLOR=blue>,</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> } ) <TT><FONT COLOR=blue>#</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>class-path</FONT></I></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>poly-typexpr</FONT></I></TT></TD>
<TD ALIGN=right NOWRAP>::=</TD>
<TD ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> { <TT><FONT COLOR=blue>'</FONT></TT> <TT><I><FONT COLOR=maroon>ident</FONT></I></TT> }<SUP><FONT SIZE=2>+</FONT></SUP> <TT><FONT COLOR=blue>.</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>method-type</FONT></I></TT></TD>
<TD ALIGN=right NOWRAP>::=</TD>
<TD ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>method-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>poly-typexpr</FONT></I></TT></TD>
</TR></TABLE></DIV><BR>
The table below shows the relative precedences and associativity of
operators and non-closed type constructions. The constructions with
higher precedences come first.
<A NAME="@manual.kwd3"></A>
<BR>
<DIV ALIGN=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>
<TR><TD ALIGN=left NOWRAP>
Type constructor application</TD>
<TD ALIGN=left NOWRAP>--</TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT>*</TT></TD>
<TD ALIGN=left NOWRAP>--</TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT>-&gt;</TT></TD>
<TD ALIGN=left NOWRAP>right</TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT>as</TT></TD>
<TD ALIGN=left NOWRAP>--</TD>
</TR></TABLE></DIV><BR>
Type expressions denote types in definitions of data types as well as
in type constraints over patterns and expressions.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Type variables</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
The type expression <TT><FONT COLOR=blue>'</FONT></TT> <TT><I><FONT COLOR=maroon>ident</FONT></I></TT> stands for the type variable named
<TT><I><FONT COLOR=maroon>ident</FONT></I></TT>. The type expression <TT><FONT COLOR=blue>_</FONT></TT> stands for an anonymous type variable.
In data type definitions, type variables are names for the
data type parameters. In type constraints, they represent unspecified
types that can be instantiated by any type to satisfy the type
constraint. In general the scope of a named type variable is the
whole enclosing definition; they can only be generalized when leaving
this scope. Anonymous variables have no such restriction.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Parenthesized types</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
The type expression <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT> denotes the same type as
<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT>.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Function types</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
The type expression <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>-&gt;</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> denotes the type of
functions mapping arguments of type <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to results of type
<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB>.<BR>
<BR>
<TT><I><FONT COLOR=maroon>label</FONT></I></TT> &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>-&gt;</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> denotes the same function type, but
the argument is labeled <TT><I><FONT COLOR=maroon>label</FONT></I></TT>.<BR>
<BR>
<TT><FONT COLOR=blue>?</FONT></TT><TT><I><FONT COLOR=maroon>label</FONT></I></TT> &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>-&gt;</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> denotes the type of functions
mapping an optional labeled argument of type <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> to results of
type <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB>. That is, the physical type of the function will be
<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>option</FONT></TT> <TT><FONT COLOR=blue>-&gt;</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB>.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Tuple types</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
The type expression <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>*</FONT></TT> ... <TT><FONT COLOR=blue>*</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>
denotes the type of tuples whose elements belong to types <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB>,
... &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> respectively.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Constructed types</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
Type constructors with no parameter, as in <TT><I><FONT COLOR=maroon>typeconstr</FONT></I></TT>, are type
expressions.<BR>
<BR>
The type expression <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> &nbsp;<TT><I><FONT COLOR=maroon>typeconstr</FONT></I></TT>, where <TT><I><FONT COLOR=maroon>typeconstr</FONT></I></TT> is a type
constructor with one parameter, denotes the application of the unary type
constructor <TT><I><FONT COLOR=maroon>typeconstr</FONT></I></TT> to the type <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT>.<BR>
<BR>
The type expression (<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB>,...,&nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>) &nbsp;<TT><I><FONT COLOR=maroon>typeconstr</FONT></I></TT>, where
<TT><I><FONT COLOR=maroon>typeconstr</FONT></I></TT> is a type constructor with <I>n</I> parameters, denotes the
application of the <I>n</I>-ary type constructor <TT><I><FONT COLOR=maroon>typeconstr</FONT></I></TT> to the types
<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> through <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Aliased and recursive types</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
<A NAME="@manual.kwd4"></A><BR>
The type expression <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> <TT><FONT COLOR=blue>as</FONT></TT> <TT><FONT COLOR=blue>'</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>ident</FONT></I></TT> denotes the same type as
<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT>, and also binds the type variable <TT><I><FONT COLOR=maroon>ident</FONT></I></TT> to type <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> both
in <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> and in the remaining part of the type. If the type variable
<TT><I><FONT COLOR=maroon>ident</FONT></I></TT> actually occurs in <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT>, a recursive type is created. Recursive
types for which there exists a recursive path that does not contain
an object or variant type constructor are rejected, except when the
<TT>-rectypes</TT> mode is selected.<BR>
<BR>
If <TT><FONT COLOR=blue>'</FONT></TT> <TT><I><FONT COLOR=maroon>ident</FONT></I></TT> denotes an explicit polymorphic variable, and <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT>
denotes either an object or variant type, the row variable of <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT>
is captured by <TT><FONT COLOR=blue>'</FONT></TT> <TT><I><FONT COLOR=maroon>ident</FONT></I></TT>, and quantified upon.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Variant types</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
<DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>variant-type</FONT></I></TT></TD>
<TD ALIGN=right NOWRAP>::=</TD>
<TD ALIGN=left NOWRAP>
 [ <TT><FONT COLOR=blue>|</FONT></TT> ] <TT><I><FONT COLOR=maroon>tag-spec</FONT></I></TT> &nbsp;{ <TT><FONT COLOR=blue>|</FONT></TT> <TT><I><FONT COLOR=maroon>tag-spec</FONT></I></TT> }</TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>&gt;</FONT></TT> [ <TT><I><FONT COLOR=maroon>tag-spec</FONT></I></TT> ] &nbsp;{ <TT><FONT COLOR=blue>|</FONT></TT> <TT><I><FONT COLOR=maroon>tag-spec</FONT></I></TT> }</TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>&lt;</FONT></TT> [ <TT><FONT COLOR=blue>|</FONT></TT> ] <TT><I><FONT COLOR=maroon>tag-spec-full</FONT></I></TT> &nbsp;{ <TT><FONT COLOR=blue>|</FONT></TT> <TT><I><FONT COLOR=maroon>tag-spec-full</FONT></I></TT> } &nbsp;[ <TT><FONT COLOR=blue>&gt;</FONT></TT> { <TT><FONT COLOR=blue>`</FONT></TT><TT><I><FONT COLOR=maroon>tag-name</FONT></I></TT> }<SUP><FONT SIZE=2>+</FONT></SUP> ]</TD>
</TR>
<TR><TD ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>tag-spec</FONT></I></TT></TD>
<TD ALIGN=right NOWRAP>::=</TD>
<TD ALIGN=left NOWRAP>
 <TT><FONT COLOR=blue>`</FONT></TT><TT><I><FONT COLOR=maroon>tag-name</FONT></I></TT> &nbsp;[ <TT><FONT COLOR=blue>of</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> ]</TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>tag-spec-full</FONT></I></TT></TD>
<TD ALIGN=right NOWRAP>::=</TD>
<TD ALIGN=left NOWRAP>
 <TT><FONT COLOR=blue>`</FONT></TT><TT><I><FONT COLOR=maroon>tag-name</FONT></I></TT> &nbsp;[ <TT><FONT COLOR=blue>of</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> ] &nbsp;{ <TT><FONT COLOR=blue>&amp;</FONT></TT> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> }</TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT></TD>
</TR></TABLE></DIV><BR>
Variant types describe the values a polymorphic variant may take.<BR>
<BR>
The first case is an exact variant type: all possible tags are
known, with their associated types, and they can all be present.
Its structure is fully known.<BR>
<BR>
The second case is an open variant type, describing a polymorphic
variant value: it gives the list of all tags the value could take,
with their associated types. This type is still compatible with a
variant type containing more tags. A special case is the unknown
type, which does not define any tag, and is compatible with any
variant type.<BR>
<BR>
The third case is a closed variant type. It gives information about
all the possible tags and their associated types, and which tags are
known to potentially appear in values. The above exact variant type is
just an abbreviation for a closed variant type where all possible tags
are also potentially present.<BR>
<BR>
In all three cases, tags may be either specified directly in the
<I>`tag-name [...]</I> form, or indirectly through a type
expression. In this last case, the type expression must expand to an
exact variant type, whose tag specifications are inserted in its
place.<BR>
<BR>
Full specification of variant tags are only used for non-exact closed
types. They can be understood as a conjunctive type for the argument:
it is intended to have all the types enumerated in the
specification.<BR>
<BR>
Such conjunctive constraints may be unsatisfiable. In such a case the
corresponding tag may not be used in a value of this type. This
does not mean that the whole type is not valid: one can still use
other available tags.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Object types</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
An object type
<TT><FONT COLOR=blue>&lt;</FONT></TT> <TT><I><FONT COLOR=maroon>method-type</FONT></I></TT> &nbsp;{ <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>method-type</FONT></I></TT> } <TT><FONT COLOR=blue>&gt;</FONT></TT>
is a record of method types.<BR>
<BR>
Each method may have an explicit polymorphic type: { <TT><FONT COLOR=blue>'</FONT></TT> <TT><I><FONT COLOR=maroon>ident</FONT></I></TT> }<SUP><FONT SIZE=2>+</FONT></SUP>
<TT><FONT COLOR=blue>.</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT>. Explicit polymorphic variables have a local scope, and
an explicit polymorphic type can only be unified to an
equivalent one, with polymorphic variables at the same positions.<BR>
<BR>
The type <TT><FONT COLOR=blue>&lt;</FONT></TT> <TT><I><FONT COLOR=maroon>method-type</FONT></I></TT> &nbsp;{ <TT><FONT COLOR=blue>;</FONT></TT> <TT><I><FONT COLOR=maroon>method-type</FONT></I></TT> } <TT><FONT COLOR=blue>;</FONT></TT> <TT><FONT COLOR=blue>..</FONT></TT> <TT><FONT COLOR=blue>&gt;</FONT></TT> is the
type of an object with methods and their associated types are described by
<TT><I><FONT COLOR=maroon>method-type</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB>, ..., &nbsp;<TT><I><FONT COLOR=maroon>method-type</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB>, and possibly some other
methods represented by the ellipsis. This ellipsis actually is
a special kind of type variable (also called <EM>row variable</EM> in the
literature) that stands for any number of extra method types.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>#-types</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
<A NAME="s:sharp-types"></A><BR>
The type <TT><FONT COLOR=blue>#</FONT></TT> <TT><I><FONT COLOR=maroon>class-path</FONT></I></TT> is a special kind of abbreviation. This
abbreviation unifies with the type of any object belonging to a subclass
of class <TT><I><FONT COLOR=maroon>class-path</FONT></I></TT>.
It is handled in a special way as it usually hides a type variable (an
ellipsis, representing the methods that may be added in a subclass).
In particular, it vanishes when the ellipsis gets instantiated.
Each type expression <TT><FONT COLOR=blue>#</FONT></TT> <TT><I><FONT COLOR=maroon>class-path</FONT></I></TT> defines a new type variable, so
type <TT><FONT COLOR=blue>#</FONT></TT> <TT><I><FONT COLOR=maroon>class-path</FONT></I></TT> <TT><FONT COLOR=blue>-&gt;</FONT></TT> <TT><FONT COLOR=blue>#</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>class-path</FONT></I></TT> is usually not the same as
type (<TT><FONT COLOR=blue>#</FONT></TT> <TT><I><FONT COLOR=maroon>class-path</FONT></I></TT> <TT><FONT COLOR=blue>as</FONT></TT> <TT><FONT COLOR=blue>'</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>ident</FONT></I></TT>) <TT><FONT COLOR=blue>-&gt;</FONT></TT> <TT><FONT COLOR=blue>'</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>ident</FONT></I></TT>.
<BR>
<BR>
Use of #-types to abbreviate variant types is deprecated.
If <TT>t</TT> is an exact variant type then <TT>#t</TT> translates to <TT>[&lt; t]</TT>,
and <TT><FONT COLOR=blue>#t[&gt;</FONT></TT> <TT><FONT COLOR=blue>`tag</FONT></TT><SUB><FONT SIZE=2>1</FONT></SUB> ...<TT><FONT COLOR=blue>`tag</FONT></TT><SUB><FONT SIZE=2><I>k</I></FONT></SUB><TT><FONT COLOR=blue>]</FONT></TT> translates to 
<TT><FONT COLOR=blue>[&lt;</FONT></TT> <TT><FONT COLOR=blue>t</FONT></TT> <TT><FONT COLOR=blue>&gt;</FONT></TT> <TT><FONT COLOR=blue>`tag</FONT></TT><SUB><FONT SIZE=2>1</FONT></SUB> ...<TT><FONT COLOR=blue>`tag</FONT></TT><SUB><FONT SIZE=2><I>k</I></FONT></SUB><TT><FONT COLOR=blue>]</FONT></TT><BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Variant and record types</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
There are no type expressions describing (defined) variant types nor
record types, since those are always named, i.e. defined before use
and referred to by name. Type definitions are described in
section&nbsp;<A HREF="manual016.html#s:type-defs">6.8.1</A>.

<BR>
<BR>
<HR>
<A HREF="manual011.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual008.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="manual013.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>