From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 5CB42D45F for ; Mon, 31 Oct 2005 18:20:31 +0100 (CET) Received: from ash25e.internode.on.net (ash25e.internode.on.net [203.16.214.182]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j9VHKS96009970 for ; Mon, 31 Oct 2005 18:20:30 +0100 Received: from rosella (ppp7-104.lns1.syd7.internode.on.net [59.167.7.104]) by ash25e.internode.on.net (8.12.9/8.12.6) with ESMTP id j9VHKFaK078934; Tue, 1 Nov 2005 03:50:16 +1030 (CST) (envelope-from skaller@users.sourceforge.net) Subject: Re: [Caml-list] Stdlib From: skaller To: jtbryant@valdosta.edu Cc: caml-list@yquem.inria.fr In-Reply-To: <1130769705.488.16.camel@starlight> References: <1130769705.488.16.camel@starlight> Content-Type: text/plain Date: Tue, 01 Nov 2005 04:20:15 +1100 Message-Id: <1130779215.11424.21.camel@rosella> Mime-Version: 1.0 X-Mailer: Evolution 2.2.1.1 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4366525D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 stdlib:01 stl:01 iter:01 stl:01 api:01 functorize:01 ocaml:01 polymorphism:01 functor:01 abstracted:01 non-trivial:01 haskell:01 hackery:01 overloading:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Mon, 2005-10-31 at 09:41 -0500, Jonathan Bryant wrote: > Quick (and rather random question) about the standard library. I > noticed that, like the STL, many of the modules are very similar and > implement many of the same functions (iter, map, etc.). Unlike the STL > or the Java Standard API, these modules are each completely > independent. Why hasn't there been a push to do something like > functorize these modules? Because the technology to do that is WAY in advance of the current Ocaml. What you are asking for is *polyadic* functions, aka functorial polymorphism. For example, a fold function that works on all data structures, that is, polymorphic not just on the data type (such as int), but also the data functor (such as list). Such a function would never work with abstracted modules, it would require data types to be defined entirely algebraically. All of this can be done (I worked on a system that did it), however it is definitely non-trivial. It is well in advance of anything Haskell can do also. In fact, C++ DOES provide such functions: the STL is built on this concept. .. however the mechanism is not 'type safe': it works only by hackery based on overloading and dependent name lookup. This problem is partly solved in Extlib, which provides an equivalent concept to STL iterators. However the Extlib solution, whilst not so general as STL, is fully safe (since it is written in Ocaml .. :) -- John Skaller Felix, successor to C++: http://felix.sf.net