From: Lucas Dixon <ldixon@inf.ed.ac.uk>
To: caml-list@inria.fr, rossberg@mpi-sws.org
Subject: Re: [Caml-list] What is an applicative functor?
Date: Tue, 12 Apr 2011 22:36:11 -0400 [thread overview]
Message-ID: <4DA50C1B.2070203@inf.ed.ac.uk> (raw)
In-Reply-To: <94bd910fac5bc093e62f73e0ba76d6a1.squirrel@mail.mpi-sws.org>
Hi,
On 08/04/2011 09:43, rossberg@mpi-sws.org wrote:
>> 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.
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...)
I see that you have to pay some syntax for using functors that share a
Set, and for later functors that build on B or C. You can make a
sub-structure for the types you use, and then a bit of signature sharing
magic, and it can be done fairly reasonably, I think.
It does seem to me that if your type is always going to be the same,
then you can just define it first, and then parametrise what you do with
it... or even just refer to it later...
A fun idea is to provide some syntax for implicit module
parametrisation: have a union-style semantics for when overlapping
implicit modules are imported. (just some lightweight syntax for the above).
But do you think there is an implementational problem with this
functorisation in terms of scaling it up?
I've built a fairly large (for SML, it's 40k lines) of fairly heavily
functorised code (approx 10 functors deep), essentially using this
approach. It pushes the PolyML compiler a bit, and requires some
slightly frustrating extra 'Sharing'-substructures, but otherwise works
ok. The sharing substructures would disappear if we had a sensible
signature language.
best,
lucas
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
next prev parent reply other threads:[~2011-04-13 2:36 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-07 21:12 Dawid Toton
2011-04-07 21:49 ` Gerd Stolpmann
2011-04-08 0:44 ` [Caml-list] " Dawid Toton
2011-04-08 1:34 ` Gerd Stolpmann
2011-04-08 6:50 ` [Caml-list] " Andreas Rossberg
2011-04-08 8:04 ` Alain Frisch
2011-04-08 8:20 ` Jacques Garrigue
2011-04-08 8:38 ` Jacques Garrigue
2011-04-08 8:44 ` Alain Frisch
2011-04-08 10:09 ` Jacques Garrigue
2011-04-08 11:25 ` Julien Signoles
2011-04-08 11:58 ` Alain Frisch
2011-04-11 7:10 ` Julien Signoles
2011-04-11 7:21 ` Julien Signoles
2011-04-08 13:43 ` rossberg
2011-04-08 16:26 ` Julien Signoles
2011-04-13 2:36 ` Lucas Dixon [this message]
2011-04-13 7:23 ` Andreas Rossberg
2011-04-15 3:08 ` Lucas Dixon
2011-04-19 14:04 ` Andreas Rossberg
2011-04-08 16:43 ` Till Varoquaux
2011-04-08 17:35 ` Alain Frisch
2011-04-08 18:44 ` Andreas Rossberg
2011-04-08 21:23 ` Lauri Alanko
2011-04-08 21:34 ` Guillaume Yziquel
2011-04-09 11:41 ` Andreas Rossberg
2011-04-08 5:35 ` Stefan Holdermans
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DA50C1B.2070203@inf.ed.ac.uk \
--to=ldixon@inf.ed.ac.uk \
--cc=caml-list@inria.fr \
--cc=rossberg@mpi-sws.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox