From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Till Varoquaux <till@pps.jussieu.fr>
Cc: "Milan Stanojević" <milanst@gmail.com>,
"Hezekiah M. Carty" <hez@0ok.org>,
"Ashish Agarwal" <agarwal1975@gmail.com>,
"Caml List" <caml-list@inria.fr>
Subject: Re: [Caml-list] Re: "module type of" on sub-module of functor result
Date: Wed, 22 Feb 2012 18:24:57 +0100 [thread overview]
Message-ID: <CAPFanBFEjhg5BF-0aiAnXAQM7zAAQWLTAw0kMfvMKHX8R=eU0A@mail.gmail.com> (raw)
In-Reply-To: <CAHJESt2Dhf0-3xQE8Tv_XAdFdcyrVViwk3y_-AOxOymbXGHZUA@mail.gmail.com>
> [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
?
2012/2/22 Till Varoquaux <till@pps.jussieu.fr>:
> 2012/2/22 Milan Stanojević <milanst@gmail.com>d
>> On Tue, Feb 21, 2012 at 3:32 PM, Hezekiah M. Carty <hez@0ok.org> wrote:
>>> On Tue, Feb 21, 2012 at 2:37 PM, Ashish Agarwal <agarwal1975@gmail.com> wrote:
>>>> I must've accidentally deleted part of my email before hitting send. The
>>>> point was to make the first code sample compile after removing the commented
>>>> line. But that is not allowed; I get a syntax error:
>>>>
>>>> $ ocamlfind ocamlc -c -package batteries a.ml
>>>> File "a.ml", line 6, characters 38-39:
>>>> Error: Syntax error: 'end' expected
>>>> File "a.ml", line 4, characters 16-19:
>>>> Error: This 'sig' might be unmatched
>>>>
>>>> I'm wondering if there is a better solution than my second code sample.
>>>>
>>
>> I would consider this a bug. I think than any module expression than
>> can be used with "include" should be usable with "include module type
>> of"
>>
>> --
>> 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
>>
>
> Milan is right: the language grammar does say that both [include] and
> [module type of] should work on module_expr. However, based upon the
> manual(*), [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?
>
> [*]http://caml.inria.fr/pub/docs/manual-ocaml/manual019.html#module-expr
>
>
> --
> 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
>
next prev parent reply other threads:[~2012-02-22 17:25 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 [this message]
2012-02-22 18:49 ` Andreas Rossberg
2012-02-22 23:17 ` Jacques Garrigue
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='CAPFanBFEjhg5BF-0aiAnXAQM7zAAQWLTAw0kMfvMKHX8R=eU0A@mail.gmail.com' \
--to=gabriel.scherer@gmail.com \
--cc=agarwal1975@gmail.com \
--cc=caml-list@inria.fr \
--cc=hez@0ok.org \
--cc=milanst@gmail.com \
--cc=till@pps.jussieu.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