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 GAA12057; Wed, 21 Aug 2002 06:19:52 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 GAA11894 for ; Wed, 21 Aug 2002 06:19:51 +0200 (MET DST) Received: from gianther.hypbus.com (h209-139-221-5.gtconnect.net [209.139.221.5]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id g7L4JnP11357 for ; Wed, 21 Aug 2002 06:19:50 +0200 (MET DST) Received: (qmail 28603 invoked by uid 71); 21 Aug 2002 04:22:21 -0000 Received: from unknown (HELO mail.gx.ca) (127.0.0.1) by localhost with SMTP; 21 Aug 2002 04:22:21 -0000 Received: from 207.194.7.18 (SquirrelMail authenticated user nalexand) by mail.gx.ca with HTTP; Tue, 20 Aug 2002 21:22:21 -0700 (PDT) Message-ID: <1413.207.194.7.18.1029903741.squirrel@mail.gx.ca> Date: Tue, 20 Aug 2002 21:22:21 -0700 (PDT) Subject: [Caml-list] Naming polymorphic variant types From: "Nick Alexander" To: X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal Reply-To: nalexander@amavi.com X-Mailer: SquirrelMail (version 1.2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi all, Here's a file... module type TEST = sig type outer = [`A | `B] type inner = [`B] val x : outer -> outer val y : inner end module Test : TEST = struct type outer = [`A | `B] and inner = [`B] let x o = match o with | `A -> `A | `B -> `A let y = `B end let p = Test.y let q = Test.x p That when evaluated, produces... # #use "C:/Program Files/Objective Caml/test.ml";; module type TEST = sig type outer = [ `A | `B] and inner = [ `B] val x : outer -> outer val y : inner end module Test : TEST val p : Test.inner = `B File "C:/Program Files/Objective Caml/sql5.ml", line 21, characters 15-16: This expression has type Test.inner = [ `B] but is here used with type Test.outer = [ `A | `B] The first variant type does not allow tag(s) `A I'm confused. Can I get an explanation for why the parameter to a function with a sum variant type needs all summands to be possible arguments? I'm sure I'm misunderstanding the subtyping relationship, but I can't hack it. This all grew out of a desire to document code by naming polymorphic variant types, a questionable capability at best. Any light appreciated, Nick Alexander ------------------- 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