From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA19291; Thu, 29 Aug 2002 19:57:37 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA19709 for caml-list@pauillac.inria.fr; Thu, 29 Aug 2002 19:57:35 +0200 (MET DST) 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 SAA18045 for ; Thu, 29 Aug 2002 18:41:43 +0200 (MET DST) Received: from thecia.net (opcenter.thecia.net [208.218.131.20]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g7TGfdX12385 for ; Thu, 29 Aug 2002 18:41:40 +0200 (MET DST) Received: from dfan.thecia.net.thecia.net ([63.209.225.72]) by smtp.thecia.net; Thu, 29 Aug 2002 12:41:37 -0400 To: caml-list@inria.fr Subject: Re: [Caml-list] polymorphic variant question References: <3D6E45DA.51D99F9F@noos.fr> From: Dan Schmidt In-Reply-To: <3D6E45DA.51D99F9F@noos.fr> Date: 29 Aug 2002 12:41:27 -0400 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk nadji@noos.fr writes: | Hi all, | | I am puzzled by the code below which doesn't work. | | # let f = function `B -> ();; | val f : [ `B] -> unit = | # let g x = match (x:[`A|`B]) with `A -> () | y -> f y;; | Characters 51-52: | let g x = match (x:[`A|`B]) with `A -> () | y -> f y;; | ^ | This expression has type [ `A | `B] but is here used with type [ `B] | (denoting the "y" from the "f y") | | How can I say to OCaml that "y" can't be of type `A ? Try # let g x = match (x:[`A|`B]) with `A -> () | `B as y -> f y;; Dan -- http://www.dfan.org ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners