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=0.0 required=5.0 tests=none 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 72415BC0A for ; Thu, 24 May 2007 13:31:30 +0200 (CEST) Received: from ext.lri.fr (ext.lri.fr [129.175.15.4]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4OBVUkw030647 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 24 May 2007 13:31:30 +0200 Received: from smtp.lri.fr (serveur3-5 [129.175.3.5]) by ext.lri.fr (Postfix) with ESMTP id D40132020D7; Thu, 24 May 2007 13:31:29 +0200 (CEST) Received: from [129.175.4.129] (lri4-129 [129.175.4.129]) by smtp.lri.fr (Postfix) with ESMTP id 25376CED98; Thu, 24 May 2007 13:31:29 +0200 (CEST) Message-ID: <46557792.5090207@doomeer.com> Date: Thu, 24 May 2007 13:31:30 +0200 From: Romain User-Agent: Thunderbird 1.5.0.9 (X11/20070104) MIME-Version: 1.0 To: Niko Matsakis Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Extracting common information References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at lri.fr X-Miltered: at discorde with ID 46557792.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; pointer:01 node:01 node:01 pointer:01 expr:01 expr:01 userdata:98 userdata:98 caml-list:01 binary:01 data:02 data:02 tree:02 tree:02 match:02 Hi, Note that you can replace your pattern-matching with something like: let ud_type type = match type with Primitive(ud,_) | Pointer(ud,_) -> ud But although it is more factorized (which is good) it doesn't solve your problem. One solution which I like better is something like: type userdata = ... whatever you want (code location...) ... type 'a node = { user_data: userdata; node: 'a; } type type_tree = Primitive of string | Pointer of type_tree node type expr_tree = Unary of string * expr_tree node | Binary of string * expr_tree node * expr_tree node Now instead of matching on a type_tree x, you'll match on x.node. And if you want the user data you just use x.user_data. Hope it helps. -- Romain Bardou