Commit 5ed2c534 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-03-12 19:54:36 by beppe] Empty log message

Original author: beppe
Date: 2004-03-12 19:54:36+00:00
parent f9acf044
......@@ -71,22 +71,32 @@ Note that there are two rules to respect when creating your interface file:
</p>
<ul>
<li>
Every function defined in your OCaml file (<code>.mli</code>) has to
Every value defined in your OCaml file (<code>.mli</code>) has to
be defined in your CDuce file. Whereas the opposite is not
necessary: you can have much more functions in your CDuce file than in
necessary: you can have much more (toplevel) values in your CDuce file than in
your OCaml interface, only the latter are exported but the module.
</li>
<li>
Every function defined in your OCaml file has to be a supertype of your
CDuce function. By example, the previous example respects this rule (
<code>int</code> is a subtype of <code>Int</code> and <code>ML_int</code> and
<code>int</code> are equal, so <code>int -> int</code> is effectively
a supertype of <code>Int -> ML_int</code>). But <code>int -> int</code>
is not a supertype of <code>Int -> Int</code> and will be rejected by
the compiler.
Every type associated to a CDuce expression by the <code>.mli</code> file
must be <i>compatible</i> with the CDuce type of the expression.
</li>
</ul>
<p>
What <i>compatible</i> means? We have defined a canonical translation
<code>T()</code> from OCaml types to CDuce types (see next frame). The
OCaml type declared for a CDuce expression in a <code>.mli</code> is
compatible with the CDuce type of the expression if the latter is is a
subtype of the canonical translation of the former.
</p>
<p>
For instance, the previous example respects this rule since the
canonical translation of <code>int</code> is <code>ML_int</code> that
is a subtype of <code>Int</code>. Therefore the canonical translation
of <code>int -> int</code> which is <code>ML_int -> ML_int</code> is a
supertype of <code>Int -> ML_int</code>). Instead the canonical
translation of <code>int -> int</code> is not a supertype of <code>Int -> Int</code>, so if we had used this type in the definition of the CDuce function
it would be rejected by the compiler.
</p>
</box>
<box title="Translation function" link="trans">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment