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 NAA17874; Tue, 2 Jul 2002 13:15:35 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA18038 for caml-list@pauillac.inria.fr; Tue, 2 Jul 2002 13:15:34 +0200 (MET DST) 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 LAA17126 for ; Tue, 2 Jul 2002 11:49:29 +0200 (MET DST) Received: from obento.cs.caltech.edu (obento.cs.caltech.edu [131.215.44.101]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g629nRb06148; Tue, 2 Jul 2002 11:49:28 +0200 (MET DST) Received: from orchestra.cs.caltech.edu (orchestra.cs.caltech.edu [131.215.44.20]) by obento.cs.caltech.edu (Postfix) with ESMTP id 755AF400E; Tue, 2 Jul 2002 02:49:26 -0700 (PDT) Received: (from mvanier@localhost) by orchestra.cs.caltech.edu (8.11.6/8.9.3) id g629nQ606959; Tue, 2 Jul 2002 02:49:26 -0700 Date: Tue, 2 Jul 2002 02:49:26 -0700 Message-Id: <200207020949.g629nQ606959@orchestra.cs.caltech.edu> X-Authentication-Warning: orchestra.cs.caltech.edu: mvanier set sender to mvanier@cs.caltech.edu using -f From: Michael Vanier To: pierre.weis@inria.fr Cc: caml-list@inria.fr In-reply-to: <200207020914.LAA16152@pauillac.inria.fr> (message from Pierre Weis on Tue, 2 Jul 2002 11:14:58 +0200 (MET DST)) Subject: Re: [Caml-list] simple typing question References: <200207020914.LAA16152@pauillac.inria.fr> Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > From: Pierre Weis > Date: Tue, 2 Jul 2002 11:14:58 +0200 (MET DST) > Cc: caml-list@inria.fr > Content-Type: text/plain; charset=ISO-8859-1 > > > > > I imagine this has been asked and answered before, so I apologize in > > advance. > > > > Compare these two functions: > > > > # let f x = List.map (fun y -> y) x ;; > > val f : 'a list -> 'a list = > > > > and > > > > # let f = List.map (fun y -> y) ;; > > val f : '_a list -> '_a list = > > > > Why does the second use the '_a type variable instead of 'a? I thought > > that special type variables only had to do with polymorphic references. > > The FAQ states that the latter expression can't be generalized, but I don't > > really understand why. > > > > Mike > > This is explained in the FAQ of the language either in english > > http://pauillac.inria.fr/caml/FAQ/FAQ_EXPERT-eng.html#polymorphisme > > ou en français: > > http://pauillac.inria.fr/caml/FAQ/FAQ_EXPERT-fra.html#polymorphisme > > If you don't understand the explanations, please let me know. > > Cordialement, > > Pierre Weis > > INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/ > > > I *almost* understand. I understand the need for restrictions with polymorphic references. The stated rule is that for let name = expr1 ... The type of expr1 is generalized when expr1 is a function, an identifier or a constant. Otherwise the identifier name is not polymorphic (type variables are not generalized). And later it's stated that when expr1 is "map (function x -> x)" it's an application, so it isn't generalized. However, it's an application that evaluates to a function, so it seems like it would meet the stated criteria. Also, I'm not sure why such a restrictive rule is needed. If expr1 doesn't manipulate references, why can't it be generalized? Sorry to belabor this. Mike ------------------- 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