Commit 92d6eea5 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-03-09 23:26:14 by afrisch] Faire marcher interface.xml

Original author: afrisch
Date: 2004-03-09 23:26:14+00:00
parent 2f538324
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<include file="manual/namespaces.xml"/> <include file="manual/namespaces.xml"/>
<include file="manual/schema.xml"/> <include file="manual/schema.xml"/>
<include file="manual/schema_samples.xml"/> <include file="manual/schema_samples.xml"/>
<include file="manual/interface.xml"/>
<left> <left>
<p> <p>
This Guide describes all CDuce's constructions. This Guide describes all CDuce's constructions.
......
...@@ -46,7 +46,7 @@ type %%ML_int%% = -1073741824 -- 1073741823 ...@@ -46,7 +46,7 @@ type %%ML_int%% = -1073741824 -- 1073741823
let %%f%% ( %%Int%% -> %%ML_int%% ) let %%f%% ( %%Int%% -> %%ML_int%% )
%%x%% & %%ML_int%% -> %%x%% %%x%% & %%ML_int%% -> %%x%%
| %%_%% -> raise "Overflow" | %%_%% -> raise "Overflow"
]]</sample> ]]></sample>
<p> <p>
And now the OCaml code in file, foo.mli: And now the OCaml code in file, foo.mli:
...@@ -54,17 +54,17 @@ And now the OCaml code in file, foo.mli: ...@@ -54,17 +54,17 @@ And now the OCaml code in file, foo.mli:
<sample><![CDATA[ <sample><![CDATA[
val %%f%% : %%int%% -> %%int%% val %%f%% : %%int%% -> %%int%%
]]</sample> ]]></sample>
<p> <p>
The function declared in foo.mli is the interface between CDuce and OCaml, The function declared in foo.mli is the interface between CDuce and OCaml,
you are free to call it from any of your OCaml programs, as in: you are free to call it from any of your OCaml programs, as in:
</p> </p>
<sample>![CDATA[ <sample><![CDATA[
let () = let () =
if Foo.f 8 <> 8 then failwith "Error" if Foo.f 8 <> 8 then failwith "Error"
]]</sample> ]]></sample>
<p> <p>
Note that there are two rules to respect when creating your interface file: Note that there are two rules to respect when creating your interface file:
...@@ -79,7 +79,7 @@ Note that there are two rules to respect when creating your interface file: ...@@ -79,7 +79,7 @@ Note that there are two rules to respect when creating your interface file:
<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 subtype of your
CDuce function. By example, the previous example respects this rule ( CDuce function. By example, the previous example respects this rule (
<code>int</code> is a subtype of <code>Int</code> and <ML_int> and <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 <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> 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 is not a subtype of <code>Int -> Int</code> and will be rejected by
...@@ -96,7 +96,7 @@ To know if a OCaml type is a subtype of a CDuce one, it is extremely simple, ...@@ -96,7 +96,7 @@ To know if a OCaml type is a subtype of a CDuce one, it is extremely simple,
you just have to follow the translation function, <code>T</code>, given by: you just have to follow the translation function, <code>T</code>, given by:
</p> </p>
<sample>![CDATA[ <sample><![CDATA[
T(%%bool%%) = %%Bool%% T(%%bool%%) = %%Bool%%
T(%%char%%) = %%Char%% T(%%char%%) = %%Char%%
T(%%int%%) = -1073741824 -- 1073741823 T(%%int%%) = -1073741824 -- 1073741823
...@@ -106,7 +106,7 @@ T(%%t->u%%) = T(%%t%%)->T(%%u%%) ...@@ -106,7 +106,7 @@ T(%%t->u%%) = T(%%t%%)->T(%%u%%)
T(%%A%%) = `A T(%%A%%) = `A
T(%%A of t%%) = ( `A, T(%%t%%) ) 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%%) } (logically)
]]</sample> ]]></sample>
</box> </box>
...@@ -130,8 +130,9 @@ CDuce and OCaml source codes. To do that simply the follow those instructions: ...@@ -130,8 +130,9 @@ CDuce and OCaml source codes. To do that simply the follow those instructions:
<li> <li>
Build your final binary but do not forget to link it with Build your final binary but do not forget to link it with
<code>cDuce_all.cma</code> library with contains CDuce interpreter. To <code>cDuce_all.cma</code> library with contains CDuce interpreter. To
do that, just run <code>ocamlc <...> cDuce_all.cma ...</code>. do that, just run <code><![CDATA[ocamlc <...> cDuce_all.cma ...]]></code>.
</li> </li>
</ul> </ul>
</box> </box>
</page>
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