<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/01/7fee1b5b613aa3d71ce448d60403241e"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2003-01-07T12:39:49"
  subject="Re: [Caml-list] type problem with camlp4"
  prev="2003/01/8fb51787be19c5a51bde1b15e3640728"
  next="2003/01/507496d13f3e4adba7d2906519ff3b92"
  prev-in-thread="2003/01/ffa553f7b474e1e0d8832df3cc727cf6"
  next-in-thread="2003/01/676a8e37ee6228f5e1705ee7a8ffabb0"
  prev-thread="2003/01/43e79a58009853705b48ca36fcab5c69"
  next-thread="2003/01/8fb51787be19c5a51bde1b15e3640728"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] type problem with camlp4">
<msg 
  url="2003/01/ffa553f7b474e1e0d8832df3cc727cf6"
  from="Pietro Abate &lt;Pietro.Abate@a...&gt;"
  author="Pietro Abate"
  date="2003-01-07T03:59:05"
  subject="[Caml-list] type problem with camlp4">
<msg 
  url="2003/01/7fee1b5b613aa3d71ce448d60403241e"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2003-01-07T12:39:49"
  subject="Re: [Caml-list] type problem with camlp4">
<msg 
  url="2003/01/676a8e37ee6228f5e1705ee7a8ffabb0"
  from="Pietro Abate &lt;Pietro.Abate@a...&gt;"
  author="Pietro Abate"
  date="2003-01-07T22:36:50"
  subject="Re: [Caml-list] type problem with camlp4">
<msg 
  url="2003/01/87d5f328c77313794e409877b61422fb"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2003-01-08T02:31:37"
  subject="Re: [Caml-list] type problem with camlp4">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
Hi,

On Tue, Jan 07, 2003 at 02:57:10PM +1100, Pietro Abate wrote:

&gt; I have a problem expanding an &lt;:expr&lt;&gt;&gt; quotation.
&gt; the code snippet below raise this error
&gt; ocamlc -c -pp "camlp4o pa_extend.cmo q_MLast.cmo" -I
&gt; /usr/lib/ocaml/camlp4 test.ml
&gt; File "test.ml", line 19, characters 13-42:
&gt; This expression has type MLast.patt * ff but is here used with type
&gt;   MLast.patt * MLast.expr

You seem to mistake the "compiler" level and the "program" level. In
the "compiler" (Camlp4) level, you need not define your type "ff" and
its constructors A1 and A2: they belong actually to the "program"
level. I mean: they need to be defined only in the files using your
syntax extension test.cmo (compiled by camlp4o ./test.cmo ...)

In the syntax tree, they cannot appear as things of type "tt" since
Camlp4 cannot know all possible defined types. At this level, your
constructor is just "syntax tree of a constructor" and the constructor
name is just a string.

The good method is:

&gt;     el:
&gt;         [[ n = LIDENT -&gt;
&gt;             let a = &lt;:expr&lt; A1 &gt;&gt; in
&gt;             (&lt;:patt&lt;$lid:n$&gt;&gt;,&lt;:expr&lt;$a$&gt;&gt;) ]];

or:

&gt;     el:
&gt;         [[ n = LIDENT -&gt;
&gt;             (&lt;:patt&lt;$lid:n$&gt;&gt;,&lt;:expr&lt; A1 &gt;&gt;) ]];

or:

&gt;     el:
&gt;         [[ n = LIDENT -&gt;
&gt;             let a = "A1" in
&gt;             (&lt;:patt&lt;$lid:n$&gt;&gt;,&lt;:expr&lt;$uid:a$&gt;&gt;) ]];

-- 
Daniel de RAUGLAUDRE
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

