<?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="2002/12/adca70ed0317d2ff1156d25d7bb3384b"
  from="Ken Rose &lt;kenarose@e...&gt;"
  author="Ken Rose"
  date="2002-12-10T15:33:32"
  subject="Re: [Caml-list] Camlp4: generating printers of types"
  prev="2002/12/f566cd61147cbd280839f2be813cce5a"
  next="2002/12/df3aadefe9a8021d30aa32f5dcc94da0"
  prev-in-thread="2002/12/38d206434ca03422a3daee596c95db10"
  next-in-thread="2002/12/be95aad281fdfa0b0e17d2aadce6fe33"
  prev-thread="2002/10/1dd4307f336f52923ec9c00bf50e6612"
  next-thread="2002/10/bd720bbf86918b2c2bc40fcc8d8f5f47"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Camlp4: generating printers of types">
<msg 
  url="2002/10/911fcb8a222e666411b28b0649e3d30d"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-10-09T13:13:19"
  subject="[Caml-list] Camlp4: generating printers of types">
<msg 
  url="2002/12/bda14d3a04f2eedf91905a4eb42a9207"
  from="Ken Rose &lt;kenarose@e...&gt;"
  author="Ken Rose"
  date="2002-12-10T02:02:03"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
<msg 
  url="2002/12/38d206434ca03422a3daee596c95db10"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-12-10T12:25:03"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
<msg 
  url="2002/12/adca70ed0317d2ff1156d25d7bb3384b"
  from="Ken Rose &lt;kenarose@e...&gt;"
  author="Ken Rose"
  date="2002-12-10T15:33:32"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
<msg 
  url="2002/12/be95aad281fdfa0b0e17d2aadce6fe33"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-12-10T17:38:21"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
</msg>
</msg>
</msg>
<msg 
  url="2002/12/78f7eb64b20320970621cfe5b9407fa8"
  from="Damien Doligez &lt;damien.doligez@i...&gt;"
  author="Damien Doligez"
  date="2002-12-10T13:21:15"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
</msg>
</msg>
<msg 
  url="2002/10/c2f4146f681d505fc6e36fd0892119d5"
  from="Markus Mottl &lt;markus@o...&gt;"
  author="Markus Mottl"
  date="2002-10-09T17:18:14"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
</msg>
<msg 
  url="2002/10/6b5af3e32f8ae3e379720ca547b582df"
  from="Ken Rose &lt;kenarose@e...&gt;"
  author="Ken Rose"
  date="2002-10-25T19:20:41"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
<msg 
  url="2002/10/e90a6df400ab02125298d0c75314986e"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-10-25T20:02:23"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
</msg>
<msg 
  url="2002/10/b87035709e416e656037bec29d7ea9c8"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-10-26T00:11:55"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
</msg>
</msg>
</msg>
</thread>

<contents>
Hi,

I worded things badly enough that nobody understood what I was actually
after.  What I want is help extending your automatically generated
printing functions to handle all the types I actually use.

Daniel de Rauglaudre wrote:
&gt; On Mon, Dec 09, 2002 at 06:01:41PM -0800, Ken Rose wrote:
&gt; 
&gt; &gt; 1. Is there a clean way to handle (sum) types with constructors with
&gt; &gt; multiple module qualifications?  I hacked the example to deal with
&gt; &gt; Foo.bar, but it doesn't seem to extend automatically to Foo.Bar.baz.  As
&gt; &gt; I understand it, I'd need a new pattern for each additional uid.
&gt; 
&gt; I don't understand that: in the type definition, there is no qualifications
&gt; for the constructors.

This is for a type like:

type x = A of int * Foo.t * Bar.Baz.t
       | ...

Where I don't want to have to put in 
    | &lt;:ctyp&lt; $uid:m$.$lid:s$ &gt;&gt; -&gt; &lt;:expr&lt; $uid:m$.$lid:fun_name s$ &gt;&gt;
and
    | &lt;:ctyp&lt; $uid:m2$.$uid:m$.$lid:s$ &gt;&gt; -&gt; &lt;:expr&lt;
$uid:m2$.$uid:m$.$lid:fun_name s$ &gt;&gt;

and so on into gen_print_type.  Or do I not understand what $uid:x$
does?



&gt; &gt; 2. How are tuples represented in camlp4's syntax?  This is so I can
&gt; &gt; match them when analyzing a type.
&gt; 
&gt; In Revised syntax, they are like in normal syntax, but the parentheses
&gt; are compulsory.

Here, I want to match 
type t = int * int
within gen_one_print_fun, to produce a printer instead of "failwith...".

&gt; &gt; 3. This is the big one.  When working on a type like:
&gt; &gt; type t = int
&gt; &gt; with the obvious extention to Daniel's code, the preprocessor produces
&gt; &gt; type t = int let rec print_t = print_int
&gt; &gt; Which the compiler rejects with "This kind of expression is not allowed
&gt; &gt; as right-hand side of `let rec'"  I haven't been able to figure out a
&gt; &gt; way to sneak it past, either.  What's going on here?  Why can't I rename
&gt; &gt; print_int?
&gt; 
&gt; This message of OCaml just means that there are syntactic restrictions
&gt; of the "let rec". In this case, you should produce either a "let" without
&gt; "rec" or, an eta extension: "let rec print_t x = print_int x".

I'd suspected that, though I'm still curious as to why that's so. 
Still, what I really want is a generally useful tool to produce these
useful functions, without having to spend too much time right now
learning camlp4.  It's for my regular work, where I'm building a
compiler for a DSL.  I don't understand camlp4 well enough to know how
to suppress the "rec", and I'm hoping to avoid learning, at least for a
while.  It's a great tool, but I have only so much time.

Thanks for any help you're willing to give,

 - ken
-------------------
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>

