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 SAA01243; Wed, 29 Sep 2004 18:53:26 +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 SAA00159 for ; Wed, 29 Sep 2004 18:53:25 +0200 (MET DST) Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i8TGrOm9017367 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 29 Sep 2004 18:53:24 +0200 Received: from [80.229.56.224] (helo=chetara) by ptb-relay03.plus.net with esmtp (Exim) id 1CChhk-000FT6-4n for caml-list@inria.fr; Wed, 29 Sep 2004 16:53:24 +0000 From: Jon Harrop To: caml-list Subject: Re: [Caml-list] Factoring HOFs [was Re: C++ STL...] Date: Wed, 29 Sep 2004 17:49:17 +0100 User-Agent: KMail/1.6.2 References: <20040925225246.48566.qmail@web53010.mail.yahoo.com> <200409271411.30384.jon@jdh30.plus.com> <415AD595.3020009@bik-gmbh.de> In-Reply-To: <415AD595.3020009@bik-gmbh.de> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200409291749.17226.jon@jdh30.plus.com> X-Miltered: at nez-perce with ID 415AE884.001 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 2004:99 32,:01 florian:01 hars:01 subtlety:01 val:01 mapmap:99 val:01 mapmap:99 recursion:01 polymorphic:01 polymorphic:01 typing:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wednesday 29 September 2004 16:32, Florian Hars wrote: > I made the same error at first, but this is a completely different > function: 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 = # let mapmap2 g f x = map_2 List.map g f x;; val mapmap2 : ('a -> 'a) -> ('a -> 'a) -> 'a list -> 'a list = Rather than being equivalent to: # let mapmap g f x = List.map g (List.map f x);; val mapmap : ('a -> 'b) -> ('c -> 'a) -> 'c list -> 'b list = It looks like the "m" argument to map_2 is assumed to have the same type when applied to "f x" as when applied to "g (f x)". Sounds like this might be related to polymorphic recursion... Cheers, Jon. ------------------- 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