<?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/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"
  prev="2002/12/167a6c6cd1366f96e94bab06a3535858"
  next="2002/12/a35e9a667edfd52c36feaaab51a66de6"
  prev-in-thread="2002/10/911fcb8a222e666411b28b0649e3d30d"
  next-in-thread="2002/12/38d206434ca03422a3daee596c95db10"
  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>
Daniel de Rauglaudre wrote:
&gt; 
&gt; Hi everybody,
&gt; 
&gt; In Camlp4 tutorial (current version), I added a section explaining how
&gt; to make a syntax extension which, when loaded, automatically generates
&gt; printers of all your types:
&gt; 
&gt; For example, if your input file contains:
&gt; 
&gt;     type colour = Red | Green | Blue
&gt; 
&gt; this will be interpreted like this:
&gt; 
&gt;     type colour = Red | Green | Blue
&gt;     let print_colour =
&gt;       function
&gt;         Red -&gt; print_string "Red"
&gt;       | Green -&gt; print_string "Green"
&gt;       | Blue -&gt; print_string "Blue"


I've been working on extending this to more general types, which I
suppose would be easy for someone who's had some practice with camlp4. 
I'm running into 2 problems, and anticipating a third one.

1. Is there a clean way to handle (sum) types with constructors with
multiple module qualifications?  I hacked the example to deal with
Foo.bar, but it doesn't seem to extend automatically to Foo.Bar.baz.  As
I understand it, I'd need a new pattern for each additional uid.

2. How are tuples represented in camlp4's syntax?  This is so I can
match them when analyzing a type.

3. This is the big one.  When working on a type like:

type t = int

with the obvious extention to Daniel's code, the preprocessor produces

type t = int let rec print_t = print_int

Which the compiler rejects with "This kind of expression is not allowed
as right-hand side of `let rec'"  I haven't been able to figure out a
way to sneak it past, either.  What's going on here?  Why can't I rename
print_int?

Thanks

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

