caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Andreas Rossberg <rossberg@mpi-sws.org>
To: Lucas Dixon <ldixon@inf.ed.ac.uk>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] What is an applicative functor?
Date: Tue, 19 Apr 2011 16:04:50 +0200	[thread overview]
Message-ID: <BD82FD20-A555-4AF1-BBB5-4A420727E361@mpi-sws.org> (raw)
In-Reply-To: <4DA7B6BE.8090605@inf.ed.ac.uk>

On Apr 15, 2011, at 05.08 h, Lucas Dixon wrote:
> On 13/04/2011 03:23, Andreas Rossberg wrote:
>> 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.
>
> My feeling was that a little improvement on the syntax of signatures  
> and sharing would deal with these issues fairly easily.

I think this is very much a semantic problem, but I still would be  
interested to hear what improvements you have in mind.

> In terms of growing exponentially: that sounds like a serious  
> problem; I would expect it to grow linearly on the number of  
> dependencies. Or did you mean to use exponentially informally; as in  
> gets too bug too quick?

No, I meant it literally. One common idiom with functors is to re- 
export all parameter structures in the result, in order to have a self- 
contained result signature (and ease sharing later on). When you  
continue doing that up the entire dependency graph, then signatures  
can grow exponentially (in the depth of the dependency chain).

>> 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.
>
> I ended up pushing improvements to the type-error printing which  
> helped a lot in PolyML. That combined with a finding a style that  
> works out not too hideously: I create a sub-structure, typically  
> called "Sharing" to hold just types that are relevant to a  
> particular module. I can then use sharing on this substructure to  
> share all types and save the others painful problem to remember to  
> share every type.

Sure, such idioms can help, but I don't think they solve the general  
problem. The more dependencies you have (e.g. in some more top-level  
module) the more unstructured their relations become, and it is  
difficult to organize them in a useful way.

In a way, parameterizing out all imports is a kind of manual closure  
conversion. You wouldn't want to be forced to doing that in the small,  
and I don't see why you should in the large. I feel that it also  
exposes too much of what should be considered implementation details.

> yes, the concept of module for SML is really a functor and  
> dependencies are explicit.

I guess the underlying question is what constitutes a module? I think  
you have to distinguish modules (as individual abstractions) from  
components/libraries/packages/whatever you like to call them. The  
latter can consist of many modules. In that spectrum, there is a place  
for both definite and indefinite references to other modules. You  
often want the the latter when you cross boundaries to other  
libraries. But the current functor mechanism is not an adequate means  
for expressing them, because it cannot be used at that level.

/Andreas


  reply	other threads:[~2011-04-19 14:05 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
2011-04-13  7:23               ` Andreas Rossberg
2011-04-15  3:08                 ` Lucas Dixon
2011-04-19 14:04                   ` Andreas Rossberg [this message]
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=BD82FD20-A555-4AF1-BBB5-4A420727E361@mpi-sws.org \
    --to=rossberg@mpi-sws.org \
    --cc=caml-list@inria.fr \
    --cc=ldixon@inf.ed.ac.uk \
    /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;
as well as URLs for NNTP newsgroup(s).