From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p3D7O8kc001318 for ; Wed, 13 Apr 2011 09:24:08 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao4AADJPpU2LEwExkWdsb2JhbACmCBQBAQEBCQsLBxQFILVHAY5RBYVumwk X-IronPort-AV: E=Sophos;i="4.64,203,1301868000"; d="scan'208";a="92766950" Received: from hera.mpi-sb.mpg.de ([139.19.1.49]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 13 Apr 2011 09:23:22 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mpi-sb.mpg.de; s=mail200803; h=From:To:In-Reply-To:Subject: References:Message-Id:Content-Type:Content-Transfer-Encoding: Mime-Version:Date:Cc; bh=0bx5rizU7ZGuLCvP5bb6J9tyfZhVRhzG6dC/27N hcFs=; b=veUHS8JkaRJUEaXET3hc57nLsMeedfv75wbCcNWdYBgGW30MULZRNpD R/bc0V/37W0Eu/tdwJI3hWszNDJkLm+ReCwolU4upYb+VcHgP8pU6BmYybzQrcoU BFvP4SvbaLCgBfvHobTRaB+jzUOwDAfZ5xMBzJybI2cfUYLInFJw= Received: from zak.mpi-klsb.mpg.de ([139.19.1.27]:32976) by hera.mpi-sb.mpg.de (envelope-from ) with esmtp (Exim 4.69) id 1Q9uQ3-0003XB-59; Wed, 13 Apr 2011 09:23:21 +0200 Received: from mnch-5d86743c.pool.mediaways.net ([93.134.116.60]:55525 helo=[192.168.178.22]) by zak.mpi-klsb.mpg.de (envelope-from ) with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.69) id 1Q9uQ2-0006Su-Gn; Wed, 13 Apr 2011 09:23:18 +0200 From: Andreas Rossberg To: Lucas Dixon In-Reply-To: <4DA50C1B.2070203@inf.ed.ac.uk> 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> <94bd910fac5bc093e62f73e0ba76d6a1.squirrel@mail.mpi-sws.org> <4DA50C1B.2070203@inf.ed.ac.uk> Message-Id: <7123693C-B554-4944-9234-EA5E465E42B1@mpi-sws.org> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Date: Wed, 13 Apr 2011 09:23:17 +0200 Cc: caml-list@inria.fr X-Mailer: Apple Mail (2.936) Subject: Re: [Caml-list] What is an applicative functor? On Apr 13, 2011, at 04:36, Lucas Dixon wrote: >> 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. > > What do you feel is the problem is with scaling this up? (maybe I'm > being dumb, but I don't see what the issue is...) The problem is that you need to turn every module using a functor into a functor itself, and eventually end up piling up the entire transitive closure of your dependency graph in your functor parameters. My experience with the early MLKit, which used this so-called "closed functor style", was that it is horrible. You need lots of functor parameters, lots of structure nesting and reexporting (the sizes of signatures can grow exponentially!), and plenty of subtle sharing constraints. And when some new code you're writing does not type check, you sometimes spend considerable time figuring out whether that was a "real" error or you just forgot some type sharing somewhere. /Andreas