caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: dumitru.potop_butucaru@inria.fr
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Bug in the module system of version 3.12.0+beta1
Date: Thu, 22 Jul 2010 15:18:39 +0900 (JST)	[thread overview]
Message-ID: <20100722.151839.48519361.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <4C473F45.6020307@inria.fr>

From: Dumitru Potop-Butucaru <dumitru.potop_butucaru@inria.fr>
> However, I still did not understand this statement of
> Jeremy Yallop:
>>> module type Abc =
>>>    functor (M:Simple) ->
>>>    sig
>>>       val x : M.t
>>>    end
>>>      
>> You're trying to treat Abc as a functor from signatures to signatures
>> (i.e. as a parameterised signature). In fact, it's something quite
>> different: it's the *type* of a functor from structures to structures.
>>    
> If I understand well, what I try to do is impossible for
> some deep theoretical reason. Can someone explain this
> to me, or point me to a relevant paper explaining it?

I think this is not a question of impossibility, rather of
misunderstanding of the relation between modules and signatures.
A module type describes modules, it does not replace them.
In particular, in another mail you asked for the construct:

  module type MyModuleType(Param:ParamType) = sig ... end

But this just doesn't make sense. The type of a functor is not a
functor between module types. Just like the type "t1 * t2" describes
pairs of values of type t1 and t2, but it is not itself a pair of
types, but rather a product.

Note of course that one might want to play on the conceptual
similarity to write the two in the same way. Haskell does that a lot,
writing (t1,t2) for the product of the types t1 and t2. But if
you look at languages like Coq, where types are also values, this
kind of overloading seems dangerous.

Another similar misunderstanding is when you write
      include Abc(module type of IntSet)
This statement is doubly wrong: first you cannot apply a module type,
but even if Abc were a functor, it could only be applied to a module,
not a module type.
Others have explained how you can do what you intended, in two
different ways. 
The classical way is to use a real functor, returning a signature
enclosed in a module, since there is no way to return a signature
alone. There is nothing against applying functors inside signatures.
The new solution in 3.12 is to use a variant of the "with"
construct, which does exactly what you want, i.e. it turns a
signature into a "function" returning a signature.

Hope this helps,

Jacques Garrigue


  parent reply	other threads:[~2010-07-22  6:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-21 13:38 Dumitru Potop-Butucaru
2010-07-21 14:13 ` [Caml-list] " Jeremy Yallop
2010-07-21 15:49   ` rossberg
2010-07-21 18:41   ` Dumitru Potop-Butucaru
2010-07-22  2:29     ` Alain Frisch
2010-07-22  6:36       ` Dumitru Potop-Butucaru
2010-07-22  6:18     ` Jacques Garrigue [this message]
     [not found]       ` <4C47E768.4080507@inria.fr>
     [not found]         ` <9454F06C-C286-4A1F-8A9F-CA3B27F8E3BB@gmail.com>
2010-07-22  7:07           ` Dumitru Potop-Butucaru
2010-07-22  9:37       ` rossberg
2010-07-22 10:44         ` Jacques Garrigue
2010-07-22 12:28           ` Dumitru Potop-Butucaru

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=20100722.151839.48519361.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=dumitru.potop_butucaru@inria.fr \
    /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).