From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA28121 for caml-red; Fri, 2 Feb 2001 16:23:51 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA01344 for ; Thu, 1 Feb 2001 15:30:25 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f11EUM527904 for ; Thu, 1 Feb 2001 15:30:23 +0100 (MET) Received: from tet.kurims.kyoto-u.ac.jp (isdnppp3.kurims.kyoto-u.ac.jp [130.54.16.104]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id XAA15926; Thu, 1 Feb 2001 23:30:12 +0900 (JST) Received: from localhost (localhost [127.0.0.1]) by tet.kurims.kyoto-u.ac.jp (8.11.1/8.11.1) with ESMTP id f11EVBC10137; Thu, 1 Feb 2001 23:31:11 +0900 (JST) (envelope-from garrigue@kurims.kyoto-u.ac.jp) To: pfitzen@informatik.uni-tuebingen.de Cc: caml-list@inria.fr Subject: Re: # and polymorphic variants In-Reply-To: <200102010037.BAA12641@sunstroke.informatik.uni-tuebingen.de> References: <200102010037.BAA12641@sunstroke.informatik.uni-tuebingen.de> X-Mailer: Mew version 1.94.2 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20010201233110I.garrigue@kurims.kyoto-u.ac.jp> Date: Thu, 01 Feb 2001 23:31:10 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: weis@pauillac.inria.fr From: Juergen Pfitzenmaier > Dear ocaml users, > consider the following example: > > type t1 = [ `A of int ];; > type t2 = [ `B of string ];; > type t = [ `A of int | `B of string ];; > > let f1 (`A (x : int)) = > print_int x > and f2 (`B (x : string)) = > print_string x > and f (x : t) = > match x with > | #t1 -> f1 x (* this is not allowed !! *) > | #t2 -> f2 x;; ... > But I would like to see something clean like giving a name to the # pattern > ... > match x with > | #t1 y -> f1 y (* (y : t1) would have the same value as x *) You were pretty close to the solution ! You just have to write match x with | #t1 as y -> f1 y | #t2 as y -> f2 y logical, no? Jacques