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 p38GhbNf029057 for ; Fri, 8 Apr 2011 18:43:37 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgkCAPw6n03RVaE0kGdsb2JhbACESpQFjT4IFAEBAQEJCQ0HFAQhpVmKLIJfhGWJDQEBAwaBI4NMeASNTok2OoEi X-IronPort-AV: E=Sophos;i="4.63,324,1299452400"; d="scan'208";a="92549556" Received: from mail-fx0-f52.google.com ([209.85.161.52]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 08 Apr 2011 18:43:13 +0200 Received: by fxm6 with SMTP id 6so3861902fxm.39 for ; Fri, 08 Apr 2011 09:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=V3ANmbka1hA6mBM/HOgW5paiL/Sfjfucfh7mds6np78=; b=t+v9MwMRlau3VgZWgcZZpLTXcYBNg+51qIsvb9n2kk0j2O8wS5FQ1WXKhFLwUPaQNB +H7kGMAIxicY77KorGjguZVqtrQ/5EqTQuert/HZahoEdyGvjbfP7jnJjyUYo2ujqcZz NPvBff5vshGuTmb+ZoSO3IVVQDltGkug27nmc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=DSMrvXVpA6ke5BAmEG2Rh2hczup0+979Nwir8nwGhoeNrvRyv7bCIk/n+opx6n8LPK E3mseaOmT82KDp4s5TCFwsu+AdDmz5OYyqo/9YL3XptNDqmqGXgr2YKxGlEUFkFVnlO7 knNAKIKhINwhToCu/FxhwmJbj4HePwcXqCCkM= MIME-Version: 1.0 Received: by 10.223.98.8 with SMTP id o8mr2546913fan.22.1302280992977; Fri, 08 Apr 2011 09:43:12 -0700 (PDT) Sender: till.varoquaux@gmail.com Received: by 10.223.102.74 with HTTP; Fri, 8 Apr 2011 09:43:12 -0700 (PDT) In-Reply-To: <0F248A34-05CF-4640-B122-75C4CE7C2CD2@mpi-sws.org> References: <4D9E28D2.1050808@wp.pl> <1302212990.8429.1150.camel@thinkpad> <0F248A34-05CF-4640-B122-75C4CE7C2CD2@mpi-sws.org> Date: Fri, 8 Apr 2011 12:43:12 -0400 X-Google-Sender-Auth: 3aXDQtPHgvthnIuzxi-u4cx-y1c Message-ID: From: Till Varoquaux To: Andreas Rossberg Cc: Gerd Stolpmann , Dawid Toton , caml-list Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p38GhbNf029057 Subject: Re: [Caml-list] What is an applicative functor? On Fri, Apr 8, 2011 at 2:50 AM, Andreas Rossberg wrote: > 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 I tend to consider using Impure functors as very poor coding hygiene.. I am sure there are compelling use cases but I've yet to come across one. Providing safer types for impure functors does not seem compelling enough to justify having several kind of functors. I am not really sure I want applicative functors (based upon my experience they are pretty hard to explain and rarely buy me anything) but I balk at the idea of having both applicative and generative functors.. Till > > > -- > Caml-list mailing list.  Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > >