Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
92d6eea5
Commit
92d6eea5
authored
Jul 10, 2007
by
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
web/manual.xml
View file @
92d6eea5
...
...
@@ -10,9 +10,10 @@
<include
file=
"manual/namespaces.xml"
/>
<include
file=
"manual/schema.xml"
/>
<include
file=
"manual/schema_samples.xml"
/>
<include
file=
"manual/interface.xml"
/>
<left>
<p>
This Guide describes
all CDuce's constructions.
This Guide describes all CDuce's constructions.
</p>
<pages-toc/>
<p>
See also:
</p>
...
...
web/manual/interface.xml
View file @
92d6eea5
...
...
@@ -46,7 +46,7 @@ type %%ML_int%% = -1073741824 -- 1073741823
let %%f%% ( %%Int%% ->
%%ML_int%% )
%%x%%
&
%%ML_int%% -> %%x%%
| %%_%% -> raise "Overflow"
]]
</sample>
]]
>
</sample>
<p>
And now the OCaml code in file, foo.mli:
...
...
@@ -54,17 +54,17 @@ And now the OCaml code in file, foo.mli:
<sample>
<![CDATA[
val %%f%% : %%int%% ->
%%int%%
]]
</sample>
]]
>
</sample>
<p>
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:
</p>
<sample>
![CDATA[
<sample>
<
![CDATA[
let () =
if Foo.f 8 <>
8 then failwith "Error"
]]
</sample>
]]
>
</sample>
<p>
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>
Every function defined in your OCaml file has to be a subtype of your
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
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
...
...
@@ -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:
</p>
<sample>
![CDATA[
<sample>
<
![CDATA[
T(%%bool%%) = %%Bool%%
T(%%char%%) = %%Char%%
T(%%int%%) = -1073741824 -- 1073741823
...
...
@@ -106,7 +106,7 @@ 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)
]]
</sample>
]]
>
</sample>
</box>
...
...
@@ -130,8 +130,9 @@ CDuce and OCaml source codes. To do that simply the follow those instructions:
<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>
ocamlc
<
...> cDuce_all.cma ...
</code>
.
do that, just run
<code>
<![CDATA[
ocamlc <...> cDuce_all.cma ...
]]>
</code>
.
</li>
</ul>
</box>
\ No newline at end of file
</box>
</page>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment