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 p386p29s003708 for ; Fri, 8 Apr 2011 08:51:02 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Al8AAIevnk2LEwExkWdsb2JhbACmEhQBAQEBCQsLBxQFILFTAY4RBYVt X-IronPort-AV: E=Sophos;i="4.63,322,1299452400"; d="scan'208";a="92507981" Received: from hera.mpi-sb.mpg.de ([139.19.1.49]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 08 Apr 2011 08:50:57 +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=kfoHwqkWcD2dO1mHpbHou6yXOMlHYaCcaPj284n 1QGM=; b=YxP2CJ+Zfw961RDer7gLaT4C8QuuCNsOrWFKEaD0TvHwAvPF2z6fxdv 04fAYJYYe5Tz/FdMo354JM8MtO1eUjnmrn2N/6PZ85y2Ik76K3FhdCSSha0f8mOA Lfrdn0055LH764y1UQnGT4+8YYw+6kpLzBHtNFUTlfEjVAvzt+es= Received: from infao0525.mpi-klsb.mpg.de ([139.19.1.26]:54492 helo=maniac.mpi-klsb.mpg.de) by hera.mpi-sb.mpg.de (envelope-from ) with esmtp (Exim 4.69) id 1Q85Wv-00071T-QE; Fri, 08 Apr 2011 08:50:55 +0200 Received: from mnch-5d86c5a4.pool.mediaways.net ([93.134.197.164]:61014 helo=[192.168.178.22]) by maniac.mpi-klsb.mpg.de (envelope-from ) with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.69) id 1Q85Wu-0004Rh-Lg; Fri, 08 Apr 2011 08:50:52 +0200 From: Andreas Rossberg To: Gerd Stolpmann In-Reply-To: <1302212990.8429.1150.camel@thinkpad> References: <4D9E28D2.1050808@wp.pl> <1302212990.8429.1150.camel@thinkpad> Message-Id: <0F248A34-05CF-4640-B122-75C4CE7C2CD2@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: Fri, 8 Apr 2011 08:50:52 +0200 Cc: Dawid Toton , caml-list X-Mailer: Apple Mail (2.936) Subject: Re: [Caml-list] What is an applicative functor? On Apr 7, 2011, at 23:49, Gerd Stolpmann wrote: > module Make(X : sig end) = struct type t = Variant end > module M1 = Make(struct end) > module M2 = Make(struct end) > > Now, M1.t and M2.t are incompatible - for nominal types like variants > the functors aren't applicative, and each instance is a thing of its > own: Nitpick: the Make functor is still applicative. All functors in OCaml are applicative. The fact that you get different results above is caused by the way you apply the functor, not by the way it is defined. "Applicative" distinguishes functor semantics in OCaml from that in SML, where functors are "generative", i.e. you always get new types when you apply them. Aside: In general, you really want to have both: functors with impure bodies better be generative, while functors with pure bodies should be applicative. The absence of generative functors in OCaml also is the reason that you cannot unpack a first-class module in a functor body (non-locally), because that is unsound with applicative semantics. /Andreas