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 MAA01314; Thu, 30 Sep 2004 12:13:02 +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 MAA00904 for ; Thu, 30 Sep 2004 12:13:01 +0200 (MET DST) Received: from mta1.cl.cam.ac.uk (mta1.cl.cam.ac.uk [128.232.0.15]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i8UAD1fr023428 for ; Thu, 30 Sep 2004 12:13:01 +0200 Received: from zonule.cl.cam.ac.uk ([128.232.9.23] helo=cl.cam.ac.uk ident=[IFmvqtpPtXQO5535GCq2fiPNsTBlHzyO]) by mta1.cl.cam.ac.uk with esmtp (Exim 3.092 #1) id 1CCxvo-0007By-00; Thu, 30 Sep 2004 11:13:00 +0100 X-Mailer: exmh version 2.6.3-CL 04/04/2003 with nmh-1.0.4 X-Exmh-Isig-CompType: repl X-Exmh-Isig-Folder: cslists/caml To: Jon Harrop cc: caml-list Subject: Re: [Caml-list] Factoring HOFs [was Re: C++ STL...] In-reply-to: Your message of "Wed, 29 Sep 2004 17:49:17 BST." <200409291749.17226.jon@jdh30.plus.com> Mime-Version: 1.0 Content-Type: text/plain Date: Thu, 30 Sep 2004 11:13:00 +0100 From: Keith Wansbrough Message-Id: X-Miltered: at nez-perce with ID 415BDC2D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 hofs:01 subtlety:01 val:01 forall:01 quantifiers:01 simonpj:01 ocaml:01 polymorphic:01 htm:97 nested:02 typing:03 stl:03 let:04 polymorphism:06 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Yipes! Ok, so I'm missing some typing subtlety. Why does this end up with a > single polymorphic type: > > # let map_2 m g f x = m g (m f x);; > val map_2 : ('a -> 'b -> 'b) -> 'a -> 'a -> 'b -> 'b = You want it to have type (forall 'a 'b 'f. ('a -> 'b) -> ('a 'f -> 'b 'f)) -> ('b -> 'c) -> ('a -> 'b) -> 'a 'f -> 'b 'f but OCaml doesn't allow nested quantifiers (i.e., higher-rank polymorphism). It actually wouldn't be very hard to support, if you're prepared to accept the need for the occasional type annotation - see http://research.microsoft.com/~simonpj/papers/putting/index.htm. --KW 8-) ------------------- 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