From: Jacques Le Normand <rathereasy@gmail.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] A limitation of "with type" declarations for first-class modules
Date: Tue, 20 Sep 2011 10:00:41 +0200 [thread overview]
Message-ID: <CAK0y-35JNF-5z=fj3t+79QVWmE5J-1UpT2dmBqCf6h87Ymx+Eg@mail.gmail.com> (raw)
In-Reply-To: <CADKNfhL2eqV3aSF76yy6rigPVfj+MXhjzh_b_xizbwdt3P_QZg@mail.gmail.com>
first post! let's see if anyone can do better...
module type Foo = sig type t end
module type Bar = sig type foo_t module Foo : Foo type t = foo_t end
(* compiles *)
let g (type a) (m : (module Foo with type t = a)) = ()
(* fails to compile with a syntax error *)
let f (type a) (m : (module Bar with type foo_t = a)) = ()
On Tue, Sep 20, 2011 at 3:36 AM, Yaron Minsky <yminsky@gmail.com> wrote:
> For some reason, 1st-class modules have more restrictive "with" syntax,
> which turns out to be a practical problem.
>
> The main constraint is that with constraints do not seem to be able to refer
> to sub-modules. Consider the following code snippet:
>
>> module type Foo = sig type t end
>> module type Bar = sig module Foo : Foo end
>>
>> (* compiles *)
>> let g (type a) (m : (module Foo with type t = a)) = ()
>>
>> (* fails to compile with a syntax error *)
>> let f (type a) (m : (module Bar with type Foo.t = a)) = ()
>
> Of course, ordinary modules have no such constraint. Any thoughts as to
> what is going on here, and whether it can be fixed? This has really
> restricted designs I've been using, forcing me to flatten out structures
> that are more naturally nested.
>
> y
>
next prev parent reply other threads:[~2011-09-20 8:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-20 1:36 Yaron Minsky
2011-09-20 8:00 ` Jacques Le Normand [this message]
2011-09-20 8:10 ` Yaron Minsky
2011-09-20 9:03 ` Alain Frisch
2011-09-20 9:23 ` Jacques Le Normand
2011-09-20 10:07 ` Yaron Minsky
2011-09-20 10:13 ` Yaron Minsky
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='CAK0y-35JNF-5z=fj3t+79QVWmE5J-1UpT2dmBqCf6h87Ymx+Eg@mail.gmail.com' \
--to=rathereasy@gmail.com \
--cc=caml-list@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