From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=5.0 tests=AWL,DNS_FROM_RFC_POST, HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id A4829BBAF for ; Sun, 14 Jun 2009 23:10:33 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiQDAIkENUrRVdvVkWdsb2JhbACCITGVNT8BAQEBCQkMBxGoTIEYjWMBAwIEhAkF X-IronPort-AV: E=Sophos;i="4.42,218,1243807200"; d="scan'208";a="29524785" Received: from mail-ew0-f213.google.com ([209.85.219.213]) by mail3-smtp-sop.national.inria.fr with ESMTP; 14 Jun 2009 23:10:30 +0200 Received: by ewy9 with SMTP id 9so2619498ewy.27 for ; Sun, 14 Jun 2009 14:10:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=6IUwFCfqA1nM91c0hBbGhBwVdFcWPgHzJSRq3E80+IY=; b=uGb2rno8GIVvLTjtRByuVEn7g2VDOeY4Ggu+BjNZ19nF3nEsI5aLyNCpzI0sieNj4C pETkjsZdrrHhGgMuj2uq4RYh3hsyW4+OOFCMsfnUw61onLIcfArDXtgtEAjmagJTU6et wY0tkf+legXPull8JKlbglrob+JwWOfNNtC1g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=jyDgyOEOpbuVJFx/NwRoVgJhQok+jRyrt8GD7W/atTAYrt1901IO8iLRfbxMhUrN7c rVQJh+Z9+z7gB9R9p4z6dfufHrLVp+rFSgmqiB8/wgABN7zQB6LGsfEB947rQy1Kt/ah Nr/Xm/kh534yD0PI99q57+Pr2j8EthNhX3/a8= MIME-Version: 1.0 Received: by 10.216.8.65 with SMTP id 43mr2072761weq.168.1245013829982; Sun, 14 Jun 2009 14:10:29 -0700 (PDT) Date: Sun, 14 Jun 2009 17:10:29 -0400 Message-ID: Subject: defining recursive types with camlp4 From: Jacques Le Normand To: caml-list caml-list Content-Type: multipart/alternative; boundary=0016364c7a1d139927046c555f67 X-Spam: no; 0.00; recursive:01 camlp:01 ocaml:01 recursive:01 iter:01 constructors:01 iter:01 constructors:01 expr:01 ocaml:01 rec:01 rec:01 constructor:01 constructor:01 pairs:01 --0016364c7a1d139927046c555f67 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello ocaml list, I have a list of name constructor pairs and from that list I want to define a set of recursive types. I've written the following function: let type_chain _loc lst = let rec iter sofar = function | [] -> sofar | (name,constructors) :: ys -> iter <:str_item< $sofar$ and $lid:name$ = $constructor$ >> ys in match lst with (name,constructors) :: ys -> iter <:str_item< type $lid:name$ = $constructors$ >> ys | _ -> raise (Failure "no types defined") which, unfortunately, fails to type check with the error: " While expanding quotation "str_item" in a position of "expr": Parse error: illegal begin of quotation of structure item " how would I go about writing such a function? --Jacques L --0016364c7a1d139927046c555f67 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello ocaml list,
I have a list of name constructor pairs and from that = list I want to define a set of recursive types. I've written the follow= ing function:

let type_chain _loc=A0 lst =3D
=A0 let rec iter so= far =3D
=A0=A0=A0 function
=A0=A0=A0=A0=A0 | [] -> sofar
=A0=A0=A0=A0=A0 |= (name,constructors) :: ys ->
=A0=A0=A0 =A0 iter <:str_item< $s= ofar$ and $lid:name$ =3D $constructor$=A0 >> ys
=A0 in
=A0=A0= =A0 match lst with
=A0=A0=A0 (name,constructors) :: ys ->
=A0=A0=A0 =A0 iter <:str_item< type $lid:name$ =3D $constructors$ >= ;> ys
=A0=A0=A0=A0=A0 | _ -> raise (Failure "no types define= d")

which, unfortunately, fails to type check with the error:
"
While expanding quotation "str_item" in a position of "expr&= quot;:
=A0 Parse error: illegal begin of quotation of structure item
= "

how would I go about writing such a function?

--Jacque= s L
--0016364c7a1d139927046c555f67--