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 MAA00385; Thu, 7 Feb 2002 12:21:45 +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 MAA32620 for ; Thu, 7 Feb 2002 12:21:44 +0100 (MET) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g17BLiv14417 for ; Thu, 7 Feb 2002 12:21:44 +0100 (MET) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id g17BLhp37087 for ; Thu, 7 Feb 2002 12:21:43 +0100 (CET) Received: from localhost (frisch@localhost) by clipper.ens.fr (8.9.2/jb-1.1) id MAA17259 for ; Thu, 7 Feb 2002 12:21:43 +0100 (MET) Date: Thu, 7 Feb 2002 12:21:43 +0100 (MET) From: Alain Frisch To: Caml list Subject: [Caml-list] Type variables (was: Odd Type Checking Problem) In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, On Wed, 6 Feb 2002, I wrote: > I guess this is a problem of understanding type variable scoping rules. Actually, I feel myself somewhat confused with implicit introduction and scoping of type variables. These one are refused: let f (x : 'a) = let module M = struct exception X of 'a end in ();; let f (x : 'a) = let module M = struct type t = 'a end in ();; This is accepted: let f (x : 'a) = let module M = struct type t constraint t = 'a;; exception X of t;; end in ();; but is quite useless, since both: let f (x : 'a) = let module M = struct type t constraint t = 'a;; exception X of t;; raise (X x);; end in ();; and let f (x : 'a) = let module M = struct type t constraint t = 'a;; exception X of t;; end in raise (M.X x);; are rejected by the type checker. (in "constraint ...", no new variable is introduced) Another example: let f (x : 'a) = let module M = struct type u = { a : 'a } end in ();; => rejected (Unbound type parameter 'a) (and accepted by "Objective Caml version 3.04+1 with explicit polymorphism (2002-01-07)", but with a different meaning that one could expect) Is there a way to use a type variable such as the 'a above to define types in a local structure ? -- Alain ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr