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.0 required=5.0 tests=AWL,SPF_NEUTRAL 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 457D9BC69 for ; Mon, 30 Apr 2007 23:52:55 +0200 (CEST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.173]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l3ULqsQH014897 for ; Mon, 30 Apr 2007 23:52:55 +0200 Received: by ug-out-1314.google.com with SMTP id k3so1108819ugf for ; Mon, 30 Apr 2007 14:52:54 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:mime-version:content-transfer-encoding:message-id:content-type:to:from:subject:date:x-mailer; b=BySpvdGMFyV8jHV6z+dVqZZa7U4446s0tUr1mZp26jN1kU6PLDcqzeBojaeJXHT334pNuDUerKFhrcBHBRBIOQ7BvZoWmxfdaa1ziLzxgx9ji8VQuFpvv3KGWPZWhlhV74rSFlDy+6z77OIzds3EVIClpNTZs/TD2PCncH1Eccg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:mime-version:content-transfer-encoding:message-id:content-type:to:from:subject:date:x-mailer; b=Vt9cc3ACVjicpEKMFFMwIbzCiWOyDlzH1rvcmaso5c2cWSB2cPh501a46twYv/HBWUGzyJQNzFO5uizq+g35LYOztB4oypxRbRh8rbv5nL+ebM6Q7xntirXW33aSMnSkObKP6nwBpJonQ6o2zfsqNmzYWdNx/ZhdpkzXfYTfYyM= Received: by 10.67.115.11 with SMTP id s11mr5697941ugm.1177969974688; Mon, 30 Apr 2007 14:52:54 -0700 (PDT) Received: from ?192.168.1.34? ( [83.52.237.136]) by mx.google.com with ESMTP id 5sm10543597ugc.2007.04.30.14.52.53; Mon, 30 Apr 2007 14:52:54 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v752.3) Content-Transfer-Encoding: 7bit Message-Id: <85C23368-5DC3-4ECB-BEBA-EB98E5140E33@gmail.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: Caml List From: Joel Reymont Subject: camlp4 3.10: Hashtbl.t and <:ctyp< $tp1$ . $tp2$ >> Date: Mon, 30 Apr 2007 22:52:50 +0100 X-Mailer: Apple Mail (2.752.3) X-j-chkmail-Score: MSGID : 46366536.002 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 46366536.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 hashtbl:01 ctyp:01 hashtbl:01 denoting:01 ctyp:01 camlp:01 rec:01 rec:01 assert:01 assert:01 strings:01 ident:02 ident:02 tree:02 Consider the following function. My understanding is that for, say, Hashtbl.t it should return a list of types where the 1st element represents "t" and the second represents "Hashtbl". (* [tp_path tp] takes a type. @return a module path (list of strings) denoting this type. *) let rec tp_path = function | <:ctyp< $lid:id$ >> | <:ctyp< $uid:id$ >> -> [id] | <:ctyp< $tp1$ . $tp2$ >> -> (match tp_path tp2 with [n] -> n | _ -> assert false) :: tp_path tp1 | _ -> invalid_arg "tp_path" Nicolas suggested the following approach which doesn't work because tp1 and tp2 become idents. There's a function to convert from ctyp to ident but I could not find the opposite from searching the camlp4 source tree. let rec tp_path = function | <:ctyp< $lid:id$ >> | <:ctyp< $uid:id$ >> -> [id] | <:ctyp< $id:id$ >> -> (match id with | <:ident< $tp1$ . $tp2$ >> -> (match tp_path tp2 with [n] -> n | _ -> assert false) :: tp_path tp1 | _ -> invalid_arg "tp_path") | _ -> invalid_arg "tp_path" Since Hashtbl.t is a valid type, there should be a camlp4 ctyp pattern to match it, no? Am I missing something obvious? Thanks, Joel -- http://wagerlabs.com/