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 AAA04010; Tue, 12 Mar 2002 00:36:10 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 AAA04262 for ; Tue, 12 Mar 2002 00:36:09 +0100 (MET) Received: from smtp1.home.se (smtp1.home.se [195.66.35.200]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g2BNa9102153 for ; Tue, 12 Mar 2002 00:36:09 +0100 (MET) Received: from seneca [213.114.140.224] by smtp1.home.se with Novonyx SMTP Server $Revision: 2.74 $; Tue, 12 Mar 2002 00:30:38 +0100 (ECTD) Message-ID: <018d01c1c955$79451c20$e08c72d5@invariant.se> From: =?iso-8859-1?Q?Johan_Georg_Granstr=F6m?= To: "Jeff Polakow" Cc: References: <3C8D30CA.C8CAAD91@gnp.com> Subject: Re: [Caml-list] strange match error Date: Tue, 12 Mar 2002 00:35:48 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Jeff, > I ran into a strange (I think) error and was wondering if someone > out there can help me out. > > Why does the following program: > type tt = A of string * int | B;; > let f x = print_string ((fst x)^"\n");; > let g x = match x with A y -> f y | B -> ();; > > produce the following response from ocaml? > # #use "caml_test.ml";; > type tt = A of string * int | B > val f : string * 'a -> unit = > File "caml_test.ml", line 3, characters 23-26: > The constructor A expects 2 argument(s), but is here applied to 1 > argument(s) > > Shouldn't the type reconstructor/checker realize that y is a pair? Nope, since it isn't. Try type tt = A of (string * int) | B;; if you want A to be of one argument, a pair. The syntax is a bit obscure here... In revised syntax, the first would read type tt = [A of string and int | B]; and the second type tt = [A of (string * int) | B]; which makes the difference much more clear. Yours, - Johan Granström ------------------- 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