Commit b8089bb8 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-03-10 10:31:31 by jdemouth] Some corrections.

Original author: jdemouth
Date: 2004-03-10 10:31:31+00:00
parent cd0cdfb7
......@@ -11,7 +11,7 @@ persistent datas. A really elegant and witespread technic, to fulfill
this goal, is to use XML based documents. And a really safe and robust
way to treat XML files is to write a small program in CDuce. In this,
document, we will present a way to call CDuce functions from OCaml to
let you couple the power of CDuce to the power of OCaml.
let you couple the power of CDuce with the power of OCaml.
</p>
<p>
......@@ -24,11 +24,11 @@ OCaml and call CDuce code from OCaml one.
<box title="The interface file" link="interface">
<p>
As you have probably seen CDuce uses regular expression based pattern-
matching. This feature, combined with others, makes CDuce translation to
OCaml a bit hard. That's why you are asked to provide an OCaml interface
file to help the CDuce compiler in producing needed code to let you call
CDuce from your ML programs.
As you have probably seen CDuce uses regular expression based
pattern-matching. This feature, combined with others, makes CDuce
translation to OCaml a bit hard. That's why you are asked to provide an
OCaml interface file to help the CDuce compiler in producing needed code
to let you call CDuce from your ML programs.
</p>
<p>
......@@ -74,15 +74,15 @@ Note that there are two rules to respect when creating your interface file:
Every function defined in your OCaml file (<code>.mli</code>) has to
be defined in your CDuce file. Whereas the opposite is absolutely not
needed (you can have much more functions in your CDuce file than in
your OCaml one.
your OCaml one).
</li>
<li>
Every function defined in your OCaml file has to be a subtype of your
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 subtype of <code>Int -> ML_int</code>). But <code>int -> int</code>
is not a subtype of <code>Int -> Int</code> and will be rejected by
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.
</li>
</ul>
......@@ -102,10 +102,11 @@ T(%%char%%) = %%Char%%
T(%%int%%) = -1073741824 -- 1073741823
T(%%string%%) = %%Latin1%%
T(%%unit%%) = %%[]%%
T(%%t->u%%) = T(%%t%%)->T(%%u%%)
T(%%t -> u%%) = T(%%t%%) -> T(%%u%%)
T(%%A%%) = `A
T(%%A of t%%) = ( `A, T(%%t%%) )
T(%%{ u : t }%%) = {| u : T(%%t%%) |} or { u : T(%%t%%) } (logically)
T(%%{ u : t }%%) = { u : T(%%t%%) } or {| u : T(%%t%%) |}
(depends on if it stands for a function argument or a return value).
]]></sample>
</box>
......@@ -114,7 +115,7 @@ T(%%{ u : t }%%) = {| u : T(%%t%%) |} or { u : T(%%t%%) } (logically)
<p>
When you have created a good enough interface file, you have to build both
CDuce and OCaml source codes. To do that simply the follow those instructions:
CDuce and OCaml source codes. To do that simply follow those instructions:
</p>
<ul>
......@@ -128,9 +129,10 @@ CDuce and OCaml source codes. To do that simply the follow those instructions:
(<code>.ml</code>) containing implementation of your declared functions.
</li>
<li>
Build your final binary but do not forget to link it with
<code>cDuce_all.cma</code> library with contains CDuce interpreter. To
do that, just run <code><![CDATA[ocamlc <...> cDuce_all.cma ...]]></code>.
Build your final binary but do not forget to link it against
<code>cDuce_all.cma</code> library which contains CDuce interpreter. To
do that, just run
<code><![CDATA[ocamlc <...> cDuce_all.cma <...>]]></code>.
</li>
</ul>
......
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