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=1.9 required=5.0 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id BF402BC6B for ; Thu, 26 Jul 2007 14:46:52 +0200 (CEST) Received: from vsmtp1.tin.it (vsmtp1.tin.it [212.216.176.141]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l6QCkqAo001098 for ; Thu, 26 Jul 2007 14:46:52 +0200 Received: from [192.168.1.142] (88.58.218.58) by vsmtp1.tin.it (7.3.122) (authenticated as ebrocchini@virgilio.it) id 469A4E9901059055 for caml-list@inria.fr; Thu, 26 Jul 2007 14:46:51 +0200 Message-ID: <46A897A0.4030700@virgilio.it> Date: Thu, 26 Jul 2007 14:46:24 +0200 From: Massimiliano Brocchini User-Agent: Thunderbird 2.0.0.0 (X11/20070501) MIME-Version: 1.0 To: ocaml Subject: Camlp4: ctyp antiquotation and polymorphic type question References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 46A897BC.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 ctyp:01 ctyp:01 expr:01 camlp:01 'a-:01 vars:01 translated:01 compiler:01 foo:01 parser:01 virgilio:98 surrounded:98 polymorphic:01 polymorphic:01 Hi, I have a type expression stored in a string (obtained by cmigrep) and I need to attach it to a polymorphic method definition, but I can't obtain what I expected... I tried two solutions but I miserably failed: 1) with the following code let t1 = <:ctyp<$anti:quant$>> in let t2 = <:ctyp<$anti:function_type$>> in let method_type_expanded = <:ctyp< !$t1$.$t2$ >> in <:class_str_item< method $x$ : $method_type_expanded$ = $expression$ >> I get this error message: [...] While expanding quotation "ctyp" in a position of "expr": Parse error: illegal begin of quotation of type I even tried using a list instead of the first ctyp (t1) as mentioned in the old camlp4 3.07 manual: let method_type_expanded = <:ctyp< !$list:var_list$.$t2$ >> in but it doesn't work. 2) I tried building the polymorphic methods type declaration (e.g. 'a 'b. 'a->'b) by concatenation of strings let method_type = (vars ^ " . " ^ function_type) in let method_type_expanded = <:ctyp<$anti:method_type$>> in <:class_str_item< method $x$ : $method_type_expanded$ = $expression$ >> compiles and works to some extent... it adds the antiquotation in the translated .ml file which has two problems: - it is an unparsed string, so no compiler checks on it - it is surrounded by $ (e.g. method foo : $ 'a. 'a list -> 'a$ = ....) Could you please explain how to have the antiquotation correctly parsed by camlp4? Am I on the wrong path? (I don't feel like writing a parser for type expressions :( ). Regards, Massimiliano Brocchini (camlp4 beginner)