Sophie

Sophie

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

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>
 Module types (module specifications)
</TITLE>
</HEAD>
<BODY TEXT=black BGCOLOR=white>
<A HREF="manual017.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual008.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="manual019.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="htoc80"><B><FONT SIZE=5>6.10</FONT></B></A></TD>
<TD WIDTH="100%" ALIGN=center><B><FONT SIZE=5>Module types (module specifications)</FONT></B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
<BR>
Module types are the module-level equivalent of type expressions: they
specify the general shape and type properties of modules.<BR>
<BR>
<A NAME="@manual.kwd114"></A>
<A NAME="@manual.kwd115"></A>
<A NAME="@manual.kwd116"></A>
<A NAME="@manual.kwd117"></A>
<A NAME="@manual.kwd118"></A>
<A NAME="@manual.kwd119"></A>
<A NAME="@manual.kwd120"></A>
<A NAME="@manual.kwd121"></A>
<A NAME="@manual.kwd122"></A>
<A NAME="@manual.kwd123"></A>
<A NAME="@manual.kwd124"></A>
<A NAME="@manual.kwd125"></A><BR>
<DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>module-type</FONT></I></TT></TD>
<TD ALIGN=right NOWRAP>::=</TD>
<TD ALIGN=left NOWRAP>
 <TT><I><FONT COLOR=maroon>modtype-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>sig</FONT></TT> { <TT><I><FONT COLOR=maroon>specification</FONT></I></TT> &nbsp;[<TT><FONT COLOR=blue>;;</FONT></TT>] } <TT><FONT COLOR=blue>end</FONT></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
<TD ALIGN=right NOWRAP>|</TD>
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>functor</FONT></TT> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>module-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT> <TT><FONT COLOR=blue>-&gt;</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</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>module-type</FONT></I></TT> <TT><FONT COLOR=blue>with</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>mod-constraint</FONT></I></TT> &nbsp;{ <TT><FONT COLOR=blue>and</FONT></TT> <TT><I><FONT COLOR=maroon>mod-constraint</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>module-type</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>specification</FONT></I></TT></TD>
<TD ALIGN=right NOWRAP>::=</TD>
<TD ALIGN=left NOWRAP>
 <TT><FONT COLOR=blue>val</FONT></TT> <TT><I><FONT COLOR=maroon>value-name</FONT></I></TT> <TT><FONT COLOR=blue>:</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><FONT COLOR=blue>external</FONT></TT> <TT><I><FONT COLOR=maroon>value-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>external-declaration</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>type-definition</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>exception</FONT></TT> <TT><I><FONT COLOR=maroon>constr-decl</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>class-specification</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>classtype-definition</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>module</FONT></TT> <TT><I><FONT COLOR=maroon>module-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</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>module</FONT></TT> <TT><I><FONT COLOR=maroon>module-name</FONT></I></TT> &nbsp;{ <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>module-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT> }
 <TT><FONT COLOR=blue>:</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</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>module</FONT></TT> <TT><FONT COLOR=blue>type</FONT></TT> <TT><I><FONT COLOR=maroon>modtype-name</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>module</FONT></TT> <TT><FONT COLOR=blue>type</FONT></TT> <TT><I><FONT COLOR=maroon>modtype-name</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</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>open</FONT></TT> <TT><I><FONT COLOR=maroon>module-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>include</FONT></TT> <TT><I><FONT COLOR=maroon>module-type</FONT></I></TT></TD>
</TR>
<TR><TD ALIGN=right NOWRAP>
<TT><I><FONT COLOR=maroon>mod-constraint</FONT></I></TT></TD>
<TD ALIGN=right NOWRAP>::=</TD>
<TD ALIGN=left NOWRAP>
 <TT><FONT COLOR=blue>type</FONT></TT> [<TT><I><FONT COLOR=maroon>type-parameters</FONT></I></TT>] &nbsp;<TT><I><FONT COLOR=maroon>typeconstr</FONT></I></TT> <TT><FONT COLOR=blue>=</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><FONT COLOR=blue>module</FONT></TT> <TT><I><FONT COLOR=maroon>module-path</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>extended-module-path</FONT></I></TT></TD>
</TR></TABLE></DIV><BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#7fff7f"><DIV ALIGN=center><TABLE>
<TR><TD><A NAME="htoc81"><B><FONT SIZE=4>6.10.1</FONT></B></A></TD>
<TD WIDTH="100%" ALIGN=center><B><FONT SIZE=4>Simple module types</FONT></B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
The expression <TT><I><FONT COLOR=maroon>modtype-path</FONT></I></TT> is equivalent to the module type bound
to the name <TT><I><FONT COLOR=maroon>modtype-path</FONT></I></TT>.
The expression <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>module-type</FONT></I></TT> <TT><FONT COLOR=blue>)</FONT></TT> denotes the same type as
<TT><I><FONT COLOR=maroon>module-type</FONT></I></TT>.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#7fff7f"><DIV ALIGN=center><TABLE>
<TR><TD><A NAME="htoc82"><B><FONT SIZE=4>6.10.2</FONT></B></A></TD>
<TD WIDTH="100%" ALIGN=center><B><FONT SIZE=4>Signatures</FONT></B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
<A NAME="@manual.kwd126"></A>
<A NAME="@manual.kwd127"></A><BR>
Signatures are type specifications for structures. Signatures
<TT><FONT COLOR=blue>sig</FONT></TT> ... <TT><FONT COLOR=blue>end</FONT></TT> are collections of type specifications for value
names, type names, exceptions, module names and module type names. A
structure will match a signature if the structure provides definitions
(implementations) for all the names specified in the signature (and
possibly more), and these definitions meet the type requirements given
in the signature.<BR>
<BR>
For compatibility with Caml Light, an optional <TT>;;</TT> is allowed after each
specification in a signature. The <TT>;;</TT> has no semantic meaning.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Value specifications</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
<A NAME="@manual.kwd128"></A><BR>
A specification of a value component in a signature is written
<TT><FONT COLOR=blue>val</FONT></TT> <TT><I><FONT COLOR=maroon>value-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT>, where <TT><I><FONT COLOR=maroon>value-name</FONT></I></TT> is the name of the
value and <TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> its expected type.<BR>
<BR>
<A NAME="@manual.kwd129"></A><BR>
<BR>
The form <TT><FONT COLOR=blue>external</FONT></TT> <TT><I><FONT COLOR=maroon>value-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>typexpr</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>external-declaration</FONT></I></TT>
is similar, except that it requires in addition the name to be
implemented as the external function specified in <TT><I><FONT COLOR=maroon>external-declaration</FONT></I></TT>
(see chapter&nbsp;<A HREF="manual032.html#c:intf-c">18</A>).<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Type specifications</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
<A NAME="@manual.kwd130"></A><BR>
A specification of one or several type components in a signature is
written <TT><FONT COLOR=blue>type</FONT></TT> <TT><I><FONT COLOR=maroon>typedef</FONT></I></TT> &nbsp;{ <TT><FONT COLOR=blue>and</FONT></TT> <TT><I><FONT COLOR=maroon>typedef</FONT></I></TT> } and consists of a sequence
of mutually recursive definitions of type names.<BR>
<BR>
Each type definition in the signature specifies an optional type
equation <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>typexp</FONT></I></TT> and an optional type representation 
<TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>constr-decl</FONT></I></TT> ... or <TT><FONT COLOR=blue>=</FONT></TT> <TT><FONT COLOR=blue>{</FONT></TT> <TT><I><FONT COLOR=maroon>label-decl</FONT></I></TT> ... <TT><FONT COLOR=blue>}</FONT></TT>.
The implementation of the type name in a matching structure must
be compatible with the type expression specified in the equation (if
given), and have the specified representation (if given). Conversely,
users of that signature will be able to rely on the type equation
or type representation, if given. More precisely, we have the
following four situations:
<DL COMPACT=compact><DT>
<B>Abstract type: no equation, no representation.</B><DD> &nbsp;<BR>
Names that are defined as abstract types in a signature can be
implemented in a matching structure by any kind of type definition
(provided it has the same number of type parameters). The exact
implementation of the type will be hidden to the users of the
structure. In particular, if the type is implemented as a variant type
or record type, the associated constructors and fields will not be
accessible to the users; if the type is implemented as an
abbreviation, the type equality between the type name and the
right-hand side of the abbreviation will be hidden from the users of the
structure. Users of the structure consider that type as incompatible
with any other type: a fresh type has been generated.<BR>
<BR>
<DT><B>Type abbreviation: an equation <TT><FONT COLOR=blue>=</FONT></TT></B><B> <TT><I><FONT COLOR=maroon>typexp</FONT></I></TT></B><B>, no representation.</B><DD> &nbsp;<BR>
The type name must be implemented by a type compatible with <TT><I><FONT COLOR=maroon>typexp</FONT></I></TT>.
All users of the structure know that the type name is
compatible with <TT><I><FONT COLOR=maroon>typexp</FONT></I></TT>.<BR>
<BR>
<DT><B>New variant type or record type: no equation, a representation.</B><DD> &nbsp;<BR>
The type name must be implemented by a variant type or record type
with exactly the constructors or fields specified. All users of the
structure have access to the constructors or fields, and can use them
to create or inspect values of that type. However, users of the
structure consider that type as incompatible with any other type: a
fresh type has been generated.<BR>
<BR>
<DT><B>Re-exported variant type or record type: an equation,
a representation.</B><DD> &nbsp;<BR>
This case combines the previous two: the representation of the type is
made visible to all users, and no fresh type is generated.
</DL>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Exception specification</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
<A NAME="@manual.kwd131"></A><BR>
The specification <TT><FONT COLOR=blue>exception</FONT></TT> <TT><I><FONT COLOR=maroon>constr-decl</FONT></I></TT> in a signature requires the
matching structure to provide an exception with the name and arguments
specified in the definition, and makes the exception available to all
users of the structure.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Class specifications</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
<A NAME="@manual.kwd132"></A><BR>
A specification of one or several classes in a signature is written
<TT><FONT COLOR=blue>class</FONT></TT> <TT><I><FONT COLOR=maroon>class-spec</FONT></I></TT> &nbsp;{ <TT><FONT COLOR=blue>and</FONT></TT> <TT><I><FONT COLOR=maroon>class-spec</FONT></I></TT> } and consists of a sequence
of mutually recursive definitions of class names.<BR>
<BR>
Class specifications are described more precisely in
section&nbsp;<A HREF="manual017.html#s:class-spec">6.9.4</A>.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Class type specifications</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
<A NAME="@manual.kwd133"></A>
<A NAME="@manual.kwd134"></A><BR>
A specification of one or several classe types in a signature is
written <TT><FONT COLOR=blue>class</FONT></TT> <TT><FONT COLOR=blue>type</FONT></TT> <TT><I><FONT COLOR=maroon>classtype-def</FONT></I></TT> { <TT><FONT COLOR=blue>and</FONT></TT> <TT><I><FONT COLOR=maroon>classtype-def</FONT></I></TT> } and
consists of a sequence of mutually recursive definitions of class type
names. Class type specifications are described more precisely in
section&nbsp;<A HREF="manual017.html#s:classtype">6.9.5</A>.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Module specifications</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
<A NAME="@manual.kwd135"></A><BR>
A specification of a module component in a signature is written
<TT><FONT COLOR=blue>module</FONT></TT> <TT><I><FONT COLOR=maroon>module-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</FONT></I></TT>, where <TT><I><FONT COLOR=maroon>module-name</FONT></I></TT> is the
name of the module component and <TT><I><FONT COLOR=maroon>module-type</FONT></I></TT> its expected type.
Modules can be nested arbitrarily; in particular, functors can appear
as components of structures and functor types as components of
signatures.<BR>
<BR>
For specifying a module component that is a functor, one may write
<DIV ALIGN=center>
<TT><FONT COLOR=blue>module</FONT></TT> <TT><I><FONT COLOR=maroon>module-name</FONT></I></TT> <TT><FONT COLOR=blue>(</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>:</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</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>name</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>:</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>)</FONT></TT>
 <TT><FONT COLOR=blue>:</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</FONT></I></TT>
</DIV>
instead of
<DIV ALIGN=center>
<TT><FONT COLOR=blue>module</FONT></TT> <TT><I><FONT COLOR=maroon>module-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT>
 <TT><FONT COLOR=blue>functor</FONT></TT> <TT><FONT COLOR=blue>(</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>:</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>)</FONT></TT> <TT><FONT COLOR=blue>-&gt;</FONT></TT> ...
 <TT><FONT COLOR=blue>-&gt;</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</FONT></I></TT>
</DIV><BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Module type specifications</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
<A NAME="@manual.kwd136"></A>
<A NAME="@manual.kwd137"></A><BR>
A module type component of a signature can be specified either as a
manifest module type or as an abstract module type.<BR>
<BR>
An abstract module type specification
<TT><FONT COLOR=blue>module</FONT></TT> <TT><FONT COLOR=blue>type</FONT></TT> <TT><I><FONT COLOR=maroon>modtype-name</FONT></I></TT> allows the name <TT><I><FONT COLOR=maroon>modtype-name</FONT></I></TT> to be
implemented by any module type in a matching signature, but hides the
implementation of the module type to all users of the signature.<BR>
<BR>
A manifest module type specification
<TT><FONT COLOR=blue>module</FONT></TT> <TT><FONT COLOR=blue>type</FONT></TT> <TT><I><FONT COLOR=maroon>modtype-name</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</FONT></I></TT>
requires the name <TT><I><FONT COLOR=maroon>modtype-name</FONT></I></TT> to be implemented by the module type
<TT><I><FONT COLOR=maroon>module-type</FONT></I></TT> in a matching signature, but makes the equality between
<TT><I><FONT COLOR=maroon>modtype-name</FONT></I></TT> and <TT><I><FONT COLOR=maroon>module-type</FONT></I></TT> apparent to all users of the signature.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Opening a module path</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
<A NAME="@manual.kwd138"></A><BR>
The expression <TT><FONT COLOR=blue>open</FONT></TT> <TT><I><FONT COLOR=maroon>module-path</FONT></I></TT> in a signature does not specify
any components. It simply affects the parsing of the following items
of the signature, allowing components of the module denoted by
<TT><I><FONT COLOR=maroon>module-path</FONT></I></TT> to be referred to by their simple names <TT><I><FONT COLOR=maroon>name</FONT></I></TT> instead of
path accesses <TT><I><FONT COLOR=maroon>module-path</FONT></I></TT> <TT><FONT COLOR=blue>.</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>name</FONT></I></TT>. The scope of the <TT>open</TT>
stops at the end of the signature expression.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
<TR><TD><B>Including a signature</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
<A NAME="@manual.kwd139"></A><BR>
The expression <TT><FONT COLOR=blue>include</FONT></TT> <TT><I><FONT COLOR=maroon>module-type</FONT></I></TT> in a signature performs textual
inclusion of the components of the signature denoted by <TT><I><FONT COLOR=maroon>module-type</FONT></I></TT>.
It behaves as if the components of the included signature were copied
at the location of the <TT><FONT COLOR=blue>include</FONT></TT>. The <TT><I><FONT COLOR=maroon>module-type</FONT></I></TT> argument must
refer to a module type that is a signature, not a functor type.<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#7fff7f"><DIV ALIGN=center><TABLE>
<TR><TD><A NAME="htoc83"><B><FONT SIZE=4>6.10.3</FONT></B></A></TD>
<TD WIDTH="100%" ALIGN=center><B><FONT SIZE=4>Functor types</FONT></B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
<A NAME="@manual.kwd140"></A><BR>
The module type expression 
<TT><FONT COLOR=blue>functor</FONT></TT> <TT><FONT COLOR=blue>(</FONT></TT> <TT><I><FONT COLOR=maroon>module-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>)</FONT></TT> <TT><FONT COLOR=blue>-&gt;</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>module-type</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> 
is the type of functors (functions from modules to modules) that take
as argument a module of type <TT><I><FONT COLOR=maroon>module-type</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> and return as result a
module of type <TT><I><FONT COLOR=maroon>module-type</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB>. The module type <TT><I><FONT COLOR=maroon>module-type</FONT></I></TT><SUB><FONT SIZE=2>2</FONT></SUB> can
use the name <TT><I><FONT COLOR=maroon>module-name</FONT></I></TT> to refer to type components of the actual
argument of the functor. No restrictions are placed on the type of the
functor argument; in particular, a functor may take another functor as
argument (``higher-order'' functor).<BR>
<BR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#7fff7f"><DIV ALIGN=center><TABLE>
<TR><TD><A NAME="htoc84"><B><FONT SIZE=4>6.10.4</FONT></B></A></TD>
<TD WIDTH="100%" ALIGN=center><B><FONT SIZE=4>The <TT>with</TT> operator</FONT></B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><BR>
<A NAME="@manual.kwd141"></A><BR>
Assuming <TT><I><FONT COLOR=maroon>module-type</FONT></I></TT> denotes a signature, the expression
<TT><I><FONT COLOR=maroon>module-type</FONT></I></TT> <TT><FONT COLOR=blue>with</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>mod-constraint</FONT></I></TT> { <TT><FONT COLOR=blue>and</FONT></TT> <TT><I><FONT COLOR=maroon>mod-constraint</FONT></I></TT> } denotes
the same signature where type equations have been added to some of the
type specifications, as described by the constraints following the
<TT>with</TT> keyword. The constraint <TT><FONT COLOR=blue>type</FONT></TT> [<TT><I><FONT COLOR=maroon>type-parameters</FONT></I></TT>] &nbsp;<TT><I><FONT COLOR=maroon>typeconstr</FONT></I></TT>
<TT><FONT COLOR=blue>=</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>typexp</FONT></I></TT> adds the type equation <TT><FONT COLOR=blue>=</FONT></TT> <TT><I><FONT COLOR=maroon>typexp</FONT></I></TT> to the specification
of the type component named <TT><I><FONT COLOR=maroon>typeconstr</FONT></I></TT> of the constrained signature.
The constraint <TT><FONT COLOR=blue>module</FONT></TT> <TT><I><FONT COLOR=maroon>module-path</FONT></I></TT> <TT><FONT COLOR=blue>=</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>extended-module-path</FONT></I></TT> adds
type equations to all type components of the sub-structure denoted by
<TT><I><FONT COLOR=maroon>module-path</FONT></I></TT>, making them equivalent to the corresponding type
components of the structure denoted by <TT><I><FONT COLOR=maroon>extended-module-path</FONT></I></TT>.<BR>
<BR>
For instance, if the module type name <TT>S</TT> is bound to the signature
<PRE>
        sig type t module M: (sig type u end) end
</PRE>then <TT>S with type t=int</TT> denotes the signature
<PRE>
        sig type t=int module M: (sig type u end) end
</PRE>and <TT>S with module M = N</TT> denotes the signature
<PRE>
        sig type t module M: (sig type u=N.u end) end
</PRE>A functor taking two arguments of type <TT>S</TT> that share their <TT>t</TT> component
is written
<PRE>
        functor (A: S) (B: S with type t = A.t) ...
</PRE>

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