caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: Andreas Rossberg <rossberg@mpi-sws.org>
Cc: Gabriel Scherer <gabriel.scherer@gmail.com>,
	caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Re: "module type of" on sub-module of functor result
Date: Thu, 23 Feb 2012 08:17:49 +0900	[thread overview]
Message-ID: <823246DB-16D0-45CB-953A-3283CA077869@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <5C609F89-8739-4280-A6D9-3F78C451E0C1@mpi-sws.org>

On 2012/02/23, at 3:49, Andreas Rossberg wrote:

> On Feb 22, 2012, at 18.24 h, Gabriel Scherer wrote:
>>> [A(B)] and  [A.B] are syntacticly valid module_expr's but
>>> [A(B).C] isn't. Is this because of an inherent limitation in the
>>> module system?
>> 
>> I believe so. When you apply a functor, you may get fresh types as a
>> result -- the generative (abstract, algebraic) types of the functor
>> image. If you write `module M = A(B)`, the fresh types have a clear
>> identity: M.t, M.q etc; similarly if you pass A(B) to a functor with
>> formal parameter X, it is X.t, X.q etc. But if you write `module M =
>> A(B).C`, there is no syntactic way to name the fresh types generated
>> by the functor application; in particular, naming them A(B).t would be
>> incorrect -- because you could mix types of different applications.
>> 
>> For example, what would be the signature of A(B).C with:
>> 
>> module B = struct end
>> module A(X : sig end) = struct
>>   type t
>>   module C = struct type q = t end
>> end
>> 
>> ?
> 
> Are you perhaps thinking of SML-style generative functors here? Because with Ocaml's applicative functors F(A) in fact always returns the same abstract types, and you _can_ actually refer to types via the notation F(A).t ;-)

This is not strictly correct, because of the possibility of avoidance.
I.e. you are allowed to apply a functor to a structure rather than a path, and in that case the behavior of the functor becomes generative,
so the problem described by Gabriel really applies in that case.

Going back to the question of "module type of", it is currently implemented by typing the module expression in the usual way.
So extending it to a stronger form of module expression would require changing that, and introduce extra complexity.
Doable, but don't hold your breath...

Jacques Garrigue



  reply	other threads:[~2012-02-22 23:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-21 18:16 [Caml-list] " Ashish Agarwal
2012-02-21 19:37 ` [Caml-list] " Ashish Agarwal
2012-02-21 20:32   ` Hezekiah M. Carty
2012-02-22 16:18     ` Milan Stanojević
2012-02-22 16:40       ` Till Varoquaux
2012-02-22 17:24         ` Gabriel Scherer
2012-02-22 18:49           ` Andreas Rossberg
2012-02-22 23:17             ` Jacques Garrigue [this message]
2012-02-23 10:05               ` Gabriel Scherer
2012-02-23 14:30                 ` Ashish Agarwal
2012-02-22 17:35         ` Ashish Agarwal
2012-02-22 17:48           ` Gabriel Scherer

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=823246DB-16D0-45CB-953A-3283CA077869@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=gabriel.scherer@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).