From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p38DhDRn021825 for ; Fri, 8 Apr 2011 15:43:13 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlkAAGMQn02LEwExkWdsb2JhbACmKAEBAQEJCwsHFAUgiHqqNAGNewWFbY1S X-IronPort-AV: E=Sophos;i="4.63,323,1299452400"; d="scan'208";a="80461272" Received: from infao0809.mpi-sb.mpg.de (HELO hera.mpi-sb.mpg.de) ([139.19.1.49]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 08 Apr 2011 15:43:10 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mpi-sb.mpg.de; s=mail200803; h=Message-ID:In-Reply-To: References:Date:Subject:From:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=CSHbFifOq2EUVOlkpBelDVWTaHLWP4HlLi qdZe/y7hc=; b=R9v68FoV63BIZO0fbPqK6DkEengoPYxFHZTxQEdeh5ylZFEQ7Y 0bk7zat4ULDBFTtL8w9hgFu8nP3BDW4/dvKw6puV8wwOwtxcLjpQ9WWKPhSy9z7x NyY8KaSuK82eaGsnpGPmHtCFnK0kJd/kc+42rwH2kUYKAoarqJcPMEDJM= Received: from maniac.mpi-klsb.mpg.de ([139.19.1.26]:39638) by hera.mpi-sb.mpg.de (envelope-from ) with esmtp (Exim 4.69) id 1Q8Bxo-0008Dq-4s; Fri, 08 Apr 2011 15:43:06 +0200 Received: from local by maniac.mpi-klsb.mpg.de (envelope-from ) with local (Exim 4.69) id 1Q8Bxn-00073p-Kj; Fri, 08 Apr 2011 15:43:03 +0200 Received: from 74.125.57.233 (SquirrelMail authenticated user rossberg) by mail.mpi-sws.org with HTTP; Fri, 8 Apr 2011 15:43:03 +0200 (CEST) Message-ID: <94bd910fac5bc093e62f73e0ba76d6a1.squirrel@mail.mpi-sws.org> In-Reply-To: <4D9ECAF2.7070300@lexifi.com> References: <4D9E28D2.1050808@wp.pl> <1302212990.8429.1150.camel@thinkpad> <0F248A34-05CF-4640-B122-75C4CE7C2CD2@mpi-sws.org> <4D9EC172.1060205@lexifi.com> <4D9ECAF2.7070300@lexifi.com> Date: Fri, 8 Apr 2011 15:43:03 +0200 (CEST) From: rossberg@mpi-sws.org To: "Alain Frisch" Cc: "Jacques Garrigue" , "caml-list" User-Agent: SquirrelMail/1.4.15 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Subject: Re: [Caml-list] What is an applicative functor? > On 04/08/2011 10:20 AM, Jacques Garrigue wrote: >> Applicative functors have other advantages, like the fact you can refer to >> a >> type produced by a functor without having really applied it. I agree with Jacques. My primary argument for applicative functors is diamond import in libraries. Assume you have a set functor in a library A (e.g. the stdlib). Then there are two seperate libraries B and C, perhaps from different sources. Both need to use sets. And you want to use B and C and pass sets from one to the other. Without applicative functors, there are 3 possibilities: 1. Both B and C instantiate the Set functor separately and export the result -- then you have to convert between the incompatible set types all the time. 2. Both B and C functorize all their modules over a Set instance -- I think it's obvious that this doesn't scale. 3. A mixture of (1) and (2). Basically, this is the higher-order functor example in disguise, but dressed up in a more "real world" fashion. I believe avoiding this kind of road block is important for modularity. In ML, we don't really make that much use of functors, mainly because they are relatively heavyweight syntactically. But if you look at other languages, e.g. Haskell or C++, then their libraries heavily rely on type classes, resp templates, being "applicative" (with fairly bogus semantics in the latter case). So if we claim that ML modules are superior, I think we need applicative functors (besides generative ones). /Andreas