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 UAA16146; Tue, 17 Jun 2003 20:15:52 +0200 (MET DST) 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 UAA14906 for ; Tue, 17 Jun 2003 20:15:43 +0200 (MET DST) Received: from nexus.stwing.upenn.edu (NEXUS.STWING.UPENN.EDU [165.123.132.61]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h5HIFgH29050 for ; Tue, 17 Jun 2003 20:15:42 +0200 (MET DST) Received: from force.stwing.upenn.edu (root@force.stwing.upenn.edu [165.123.132.65]) by nexus.stwing.upenn.edu (8.12.9/8.12.9) with ESMTP id h5HIFetc021144 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 Jun 2003 14:15:41 -0400 (EDT) Received: from force.stwing.upenn.edu (ogunden@localhost [127.0.0.1]) by force.stwing.upenn.edu (8.12.9/8.12.9) with ESMTP id h5HIFdqq023975 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 Jun 2003 14:15:40 -0400 (EDT) Received: (from ogunden@localhost) by force.stwing.upenn.edu (8.12.9/8.12.9/Submit) id h5HIFdXu023973 for caml-list@inria.fr; Tue, 17 Jun 2003 14:15:39 -0400 (EDT) Date: Tue, 17 Jun 2003 14:15:39 -0400 From: Owen Gunden To: caml-list@inria.fr Subject: Re: [Caml-list] variant type Message-ID: <20030617181538.GA23197@force.stwing.upenn.edu> Mail-Followup-To: caml-list@inria.fr References: <3EEF57F7.7020705@cs.stevens-tech.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3EEF57F7.7020705@cs.stevens-tech.edu> User-Agent: Mutt/1.5.4i X-Spam: no; 0.00; owen:99 stwing:01 caml-list:01 0400,:01 3.14:01 well-typed:01 int:01 variant:02 match:02 float:02 wrote:03 let:04 upenn:06 type:07 function:09 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, Jun 17, 2003 at 02:03:35PM -0400, Ye Wu wrote: > Could you please tell me why the following doesn't work? Sure. > type shape = Square of int * int * int > |Circle of float * float * float;; > let area s = > match s with > Square (_, _, d) -> d * d > |Circle (_, _, r) -> 3.14 *. r *. r;; It's because the area function is not well-typed. If the area function is operating on a Square it wants to return an int; if it's operating on a Circle it wants to return a float. It can only return one type. Owen ------------------- 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