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 QAA27053 for caml-red; Fri, 2 Feb 2001 16:18:40 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA01379 for ; Thu, 1 Feb 2001 10:53:54 +0100 (MET) Received: from order.if.uj.edu.pl (order.if.uj.edu.pl [149.156.90.15]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f119rpn29194 for ; Thu, 1 Feb 2001 10:53:51 +0100 (MET) Received: (from ostruszk@localhost) by order.if.uj.edu.pl (8.9.3/8.9.3) id KAA09569 for caml-list@inria.fr; Thu, 1 Feb 2001 10:50:08 +0100 Date: Thu, 1 Feb 2001 10:50:08 +0100 From: "Andrzej M. Ostruszka" To: Caml List Subject: Re: # and polymorphic variants Message-ID: <20010201105008.A9515@order.if.uj.edu.pl> Mail-Followup-To: Caml List References: <200102010037.BAA12641@sunstroke.informatik.uni-tuebingen.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <200102010037.BAA12641@sunstroke.informatik.uni-tuebingen.de>; from pfitzen@informatik.uni-tuebingen.de on Thu, Feb 01, 2001 at 01:37:59AM +0100 Sender: weis@pauillac.inria.fr On Thu, Feb 01 (2001), Juergen Pfitzenmaier wrote: > and f (x : t) = > match x with > | #t1 -> f1 x (* this is not allowed !! *) > | #t2 -> f2 x;; > > The compiler can't constrain the type t of x to t1/t2 in the call to f1/f2. What about alias patterns? The following seems to work: type t1 = [ `A of int ] type t2 = [ `B of string ] type t = [ `A of int | `B of string ] let f1 (`A x) = print_int x and f2 (`B x) = print_string x and f (x : t) = match x with | #t1 as a -> f1 a | #t2 as b -> f2 b Best regards -- ____ _ ___ / | \_/ |/ _ \ Andrzej Marek Ostruszka / _ | | (_) | Instytut Fizyki, Uniwersytet Jagiellonski (Cracow) /_/ L|_|V|_|\___/ (PGP <-- finger ostruszk@order.if.uj.edu.pl)