From: Markus Mottl <markus.mottl@gmail.com>
To: Philippe Wang <mail@philippewang.info>
Cc: OCaml List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] First-class modules in functor bodies
Date: Sun, 19 May 2013 20:26:28 -0400 [thread overview]
Message-ID: <CAP_800prVWe48hrEKRSen8nTe3Uzn0f+spcBiy8htEM2R8tRTw@mail.gmail.com> (raw)
In-Reply-To: <CAAFfW_pNL_cB6FTDCd50CC5e_pYsO0RLQJkRrHTmdA=aPFFSwQ@mail.gmail.com>
In my example "module A" should be bound to "struct let x = 42 end",
not to a module containing a first-class module binding "a".
But this reminds me of a further question. The following is allowed:
-----
module M (U : sig end) = struct
module type S = sig val x : int end
let a = ((module struct let x = 42 end : S))
module A = struct
let x =
let module A = (val a) in
A.x
end
end
-----
Wouldn't the above be essentially equivalent to what I want to do?
Maybe the current restriction covers some weird corner-case that I
can't think of right now.
On Sun, May 19, 2013 at 7:07 PM, Philippe Wang <mail@philippewang.info> wrote:
> I'm curious because I don't quite understand: could you tell the
> supposed semantic differences between your code and the following
> code?
> module M (U : sig end) = struct
> module type S = sig val x : int end
> let a = ((module struct let x = 42 end : S))
> module A = struct let a = a end
> end
>
> On Sun, May 19, 2013 at 4:14 PM, Markus Mottl <markus.mottl@gmail.com> wrote:
>> Hi,
>>
>> I've been wondering why the following is disallowed:
>>
>> -----
>> module M (U : sig end) = struct
>> module type S = sig val x : int end
>> let a = ((module struct let x = 42 end : S))
>> module A = (val a)
>> end
>> -----
>>
>> The error message is:
>>
>> -----
>> File "foo.ml", line 4, characters 13-20:
>> Error: This kind of expression is not allowed within the body of a functor.
>> -----
>>
>> Making M a module by removing the functor argument works as expected.
>>
>> Is there some inherent unsoundness issue with allowing this kind of
>> use of first-class modules within functor bodies, or would it just be
>> hard adding sound support for the above to the current type system?
>>
>> Regards,
>> Markus
>>
>> --
>> Markus Mottl http://www.ocaml.info markus.mottl@gmail.com
>>
>> --
>> Caml-list mailing list. Subscription management and archives:
>> https://sympa.inria.fr/sympa/arc/caml-list
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>
>
> --
> Philippe Wang
> mail@philippewang.info
--
Markus Mottl http://www.ocaml.info markus.mottl@gmail.com
next prev parent reply other threads:[~2013-05-20 0:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-19 15:14 Markus Mottl
2013-05-19 23:07 ` Philippe Wang
2013-05-20 0:26 ` Markus Mottl [this message]
2013-05-20 7:31 ` Alain Frisch
2013-05-20 14:01 ` Markus Mottl
2013-05-20 14:07 ` Jacques Carette
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=CAP_800prVWe48hrEKRSen8nTe3Uzn0f+spcBiy8htEM2R8tRTw@mail.gmail.com \
--to=markus.mottl@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=mail@philippewang.info \
/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