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 RAA16236; Fri, 21 Feb 2003 17:16:57 +0100 (MET) 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 RAA16311 for ; Fri, 21 Feb 2003 17:16:57 +0100 (MET) Received: from iona.labri.fr (majordomo.labri.fr [147.210.8.168]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h1LGGtH29203 for ; Fri, 21 Feb 2003 17:16:55 +0100 (MET) Received: from localhost (localhost.localdomain [127.0.0.1]) by iona.labri.fr (Postfix) with ESMTP id 3175817C64; Fri, 21 Feb 2003 17:17:25 +0100 (CET) Received: from iona.labri.fr ([127.0.0.1]) by localhost (iona.labri.fr [127.0.0.1:10024]) (amavisd-new) with SMTP id 24726-08; ven, 21 fév 2003 17:17:24 +0100 (CET) Received: from Ordinateur-de-G-rard-Huet.local. (amrita.labri.fr [147.210.8.242]) by iona.labri.fr (Postfix) with ESMTP id 03FBE17C19; Fri, 21 Feb 2003 17:17:24 +0100 (CET) Date: Fri, 21 Feb 2003 17:20:10 +0100 Subject: Re: [Caml-list] Error: Type variables, that can not be generalized?! Content-Type: text/plain; charset=ISO-8859-1; format=flowed Mime-Version: 1.0 (Apple Message framework v543) Cc: caml-list@pauillac.inria.fr To: John Max Skaller From: =?ISO-8859-1?Q?G=E9rard_Huet?= In-Reply-To: <3E559D48.8030800@ozemail.com.au> Message-Id: <5972C25A-45B8-11D7-8D22-0003938819CE@inria.fr> Content-Transfer-Encoding: quoted-printable X-Mailer: Apple Mail (2.543) X-Virus-Scanned: by amavisd-new Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Le vendredi, 21 f=E9v 2003, =E0 04:30 Europe/Paris, John Max Skaller a=20= =E9crit : > BTW: I've always been baffled by the seeminly wrong nomenclature > 'generalisation' when in fact unification involves *specialising* > types/type variables. Does it refer to the seeking of the > 'most general' unifier -- that is, the most general specialisation? > > Error messages like > > "The type of this expression, ('_a, `_b) Hashtbl.t, > contains type variables that cannot be generalized" > > seem counterintuitive when in fact the problem is > that variables can't be made specific enough. Generalisation refers to transforming a free type variable into a=20 universally quantified type variable. Hindley-Milner polymorphism is more than first order=20 unification, it allows instantiation of a variable by types mutually incompatible. This is why=20= ML allows let i x =3D x in (i "a",i 0) c because i has a truly polymorphic type a -> a, which get instantiated=20 in string -> string and int -> int, even though string and int are not unifiable. Or even better : let i x =3D x in (i i);; - : '_a -> '_a =3D and indeed : let foo =3D let i x =3D x in (i i) in (foo foo);; This expression has type 'a -> 'a but is here used with type 'a The trick is that "let x=3DM in N" is treated differently from the redex=20= (fun x->N)M, and rather like M[x<-N] where the various occurrences of x may receive=20= different type assignments GH ------------------- 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