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
df24da7f
Commit
df24da7f
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2004-06-28 13:57:31 by afrisch] Bug in utf8 decoding
Original author: afrisch Date: 2004-06-28 13:57:31+00:00
parent
6c8718d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
misc/encodings.ml
View file @
df24da7f
...
@@ -80,17 +80,17 @@ struct
...
@@ -80,17 +80,17 @@ struct
|
'\000'
..
'\127'
as
c
->
|
'\000'
..
'\127'
as
c
->
Char
.
code
c
Char
.
code
c
|
'\192'
..
'\223'
as
c
->
|
'\192'
..
'\223'
as
c
->
((
Char
.
code
c
-
192
)
lsl
6
)
lor
((
Char
.
code
c
land
0b11111
)
lsl
6
)
lor
((
Char
.
code
s
.
[
i
+
1
]
-
128
))
((
Char
.
code
s
.
[
i
+
1
]
land
0b111111
))
|
'\224'
..
'\239'
as
c
->
|
'\224'
..
'\239'
as
c
->
((
Char
.
code
c
-
192
)
lsl
12
)
lor
((
Char
.
code
c
land
0b11111
)
lsl
12
)
lor
((
Char
.
code
s
.
[
i
+
1
]
-
128
)
lsl
6
)
lor
((
Char
.
code
s
.
[
i
+
1
]
land
0b111111
)
lsl
6
)
lor
((
Char
.
code
s
.
[
i
+
2
]
-
128
))
((
Char
.
code
s
.
[
i
+
2
]
land
0b111111
))
|
'\240'
..
'\248'
as
c
->
|
'\240'
..
'\248'
as
c
->
((
Char
.
code
c
-
192
)
lsl
18
)
lor
((
Char
.
code
c
land
0b11111
)
lsl
18
)
lor
((
Char
.
code
s
.
[
i
+
1
]
-
128
)
lsl
12
)
lor
((
Char
.
code
s
.
[
i
+
1
]
land
0b111111
)
lsl
12
)
lor
((
Char
.
code
s
.
[
i
+
2
]
-
128
)
lsl
6
)
lor
((
Char
.
code
s
.
[
i
+
2
]
land
0b111111
)
lsl
6
)
lor
((
Char
.
code
s
.
[
i
+
3
]
-
128
))
((
Char
.
code
s
.
[
i
+
3
]
land
0b111111
))
|
_
->
failwith
"Malformed UTF-8 bufffer"
|
_
->
failwith
"Malformed UTF-8 bufffer"
let
next
s
i
=
let
next
s
i
=
...
...
web/manual/interface.xml
View file @
df24da7f
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<!DOCTYPE page [
<!ENTITY rarr "→">
<!-- rightwards arrow, U+2192 ISOnum -->
]>
<page
name=
"manual_interfacewithocaml"
>
<page
name=
"manual_interfacewithocaml"
>
<title>
Interfacing CDuce with OCaml
</title>
<title>
Interfacing CDuce with OCaml
</title>
...
@@ -6,20 +9,44 @@
...
@@ -6,20 +9,44 @@
<box
title=
"Introduction"
link=
"intro"
>
<box
title=
"Introduction"
link=
"intro"
>
<p>
<p>
When you have to write a large program you often need to manage some
This page describe the CDuce/OCaml interface. This interface allows
persistent data. An elegant and widespread technique to fulfill
the programmer to:
this goal, is to use XML based documents. And a safe and robust
way to treat XML files is to write a small program in CDuce.
</p>
</p>
<ul>
<li>
call OCaml functions from a CDuce module;
</li>
<li>
export a CDuce as an OCaml module, by giving it an explicit OCaml signature.
</li>
</ul>
<p>
The intended usages for the interface are:
</p>
<ul>
<li>
Piggyback existing OCaml libraries, such as database,
network, GUI, datastructures;
</li>
<li>
Use CDuce as an XML layer (input/output/transformation) for OCaml
projects;
</li>
<li>
Develop fully mixed OCaml/CDuce projects.
</li>
</ul>
<p>
<p>
This page explains how to call CDuce functions from OCaml to couple. It is very
To see how to build CDuce with support for the OCaml interface,
simple all you need to do is to write an OCaml interface file for the CDuce
see the INSTALL file from the CDuce distribution.
functions you want to export to OCaml. This requires that CDuce was compiled
with support for OCaml interface (
<code>
ML_INTERFACE=true
</code>
).
</p>
</p>
</box>
<box
title=
"Translating types"
link=
"transl"
>
<p>
The heart of the interface is a mapping from OCaml types to CDuce
types. An OCaml type
<code>
t
</code>
is translated to a CDuce type
<code>
T(t)
</code>
, which is meant to be
→
isomorphic to
<code>
t
</code>
:
there exist a canonical function
<code>
t
→
T(t)
</code>
from OCaml values of type
<code>
t
</code>
to CDuce values of type
<code>
T(t)
</code>
, and another canonical function
<code>
T(t)
→
t
</code>
.
</p>
</box>
</box>
<box
title=
"The interface file"
link=
"interface"
>
<box
title=
"The interface file"
link=
"interface"
>
...
...
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