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 07D52BC0A for ; Thu, 24 May 2007 13:44:18 +0200 (CEST) Received: from smtp0.epfl.ch (smtp0.epfl.ch [128.178.50.19]) by discorde.inria.fr (8.13.6/8.13.6) with SMTP id l4OBiHbZ001506 for ; Thu, 24 May 2007 13:44:17 +0200 Received: (qmail 6720 invoked by uid 107); 24 May 2007 11:44:17 -0000 Received: from mailav3.epfl.ch (128.178.50.11) by smtp0.epfl.ch with SMTP; 24 May 2007 11:44:17 -0000 Received: from (unknown [128.178.50.22]) by MAILAV3.epfl.ch with smtp id 7e98_1a649c66_09ec_11dc_903e_0014221528b0; Thu, 24 May 2007 13:44:16 +0200 Received: from lampmac3.epfl.ch (128.178.154.94) by smtp1.epfl.ch (AngelmatoPhylax SMTP proxy); Thu, 24 May 2007 13:44:17 +0200 In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: caml-list@yquem.inria.fr Content-Transfer-Encoding: 7bit From: =?ISO-8859-1?Q?B=FCnzli_Daniel?= Subject: Re: [Caml-list] Extracting common information Date: Thu, 24 May 2007 13:44:15 +0200 To: Niko Matsakis X-Mailer: Apple Mail (2.752.2) X-Miltered: at discorde with ID 46557A91.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bunzli:01 buenzli:01 variants:01 pointer:01 expr:01 expr:01 pointer:01 polymorphic:01 caml-list:01 binary:01 binary:01 caml:02 epfl:02 tree:02 tree:02 Another solution is to use polymorphic variants [1] : type 'ud type_tree = [ `Primitive of 'ud * string | `Pointer of 'ud * 'ud type_tree ] type 'ud expr_tree = [ `Unary of 'ud * string * 'ud expr_tree | `Binary of 'ud * string * 'ud expr_tree * 'ud expr_tree ] type 'ud any_tree = [ 'ud type_tree | 'ud expr_tree ] let ud = function | `Primitive (ud, _) | `Pointer (ud, _) | `Unary (ud, _, _) | `Binary (ud, _, _, _) -> ud Daniel [1] http://caml.inria.fr/pub/docs/manual-ocaml/manual006.html#htoc41