From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p8K8AuWX014345 for ; Tue, 20 Sep 2011 10:10:59 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsQBAC9KeE7RVdQzkGdsb2JhbABCmGmHRgGHCwgUAQEBAQkJDQcUBCGBUwEBAQECAQsHAhcVARsSCwEDAQsGBQQHDQ0hIQEBDAEEAQUBAwEGEgYTCAoQh1UEl0oKi0EKglKFQjuIbQIDBoZzBIJUhRqLXYYLhAeCcT05g0I X-IronPort-AV: E=Sophos;i="4.68,410,1312149600"; d="scan'208";a="109686703" Received: from mail-vw0-f51.google.com ([209.85.212.51]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 20 Sep 2011 10:10:59 +0200 Received: by vws20 with SMTP id 20so548434vws.10 for ; Tue, 20 Sep 2011 01:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=uMbEtHAJS5REPzp0ZutOSELgHhE7i2k7Fp4ZEpGrEO8=; b=H5L/CIxKUlipsGE0ezwj3DHYAGTe7lGUAhktcx9Fwf1CGIPWPR96EBiithUz0xRI9z +HA1EGoAZFryuLQ9ipkax9+NsB2Ubzm1TqYgndpbNKKDNz8MXNszKFLRLsP+5oKwKiEn 4pTZaaDpjJHQN+JEoP6Ow/mhIJIiW7TMsKFAQ= MIME-Version: 1.0 Received: by 10.220.106.211 with SMTP id y19mr107293vco.211.1316506257141; Tue, 20 Sep 2011 01:10:57 -0700 (PDT) Received: by 10.220.152.84 with HTTP; Tue, 20 Sep 2011 01:10:57 -0700 (PDT) Reply-To: yminsky@gmail.com In-Reply-To: References: Date: Tue, 20 Sep 2011 16:10:57 +0800 Message-ID: From: Yaron Minsky To: Jacques Le Normand Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=f46d043c7baacd304f04ad5aff35 Subject: Re: [Caml-list] A limitation of "with type" declarations for first-class modules --f46d043c7baacd304f04ad5aff35 Content-Type: text/plain; charset=ISO-8859-1 I agree this works around the limitation, but it does beg the question: why is the limitation there in the first place? On Tue, Sep 20, 2011 at 4:00 PM, Jacques Le Normand wrote: > 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 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 > > > > > -- > 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 > > --f46d043c7baacd304f04ad5aff35 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I agree this works around the limitation, but it does beg the question: why= is the limitation there in the first place?

On Tue, Sep 20, 2011 at 4:00 PM, Jacques Le Normand &= lt;rathereasy@gmail.com> wrote:
first post! let&#= 39;s see if anyone can do better...

module type Foo =3D sig type t end
module type Bar =3D sig type foo_t module Foo : Foo type t =3D foo_t = =A0 end

=A0 =A0 =A0(* compiles *)
let g (type a) (m : (module Foo with type t =3D a)) =3D ()

=A0 =A0(* fails to compile with a syntax error *)
let f (type a) (m : (module Bar with type foo_t =3D a)) =3D ()


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&qu= ot; 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.=A0 Consider the following code snippet:
>
>>=A0=A0=A0=A0 module type Foo =3D sig type t end
>>=A0=A0=A0=A0 module type Bar =3D sig module Foo : Foo end
>>
>>=A0=A0=A0=A0 (* compiles *)
>>=A0=A0=A0=A0 let g (type a) (m : (module Foo with type t =3D a)) = =3D ()
>>
>>=A0=A0=A0=A0 (* fails to compile with a syntax error *)
>>=A0=A0=A0=A0 let f (type a) (m : (module Bar with type Foo.t =3D a)= ) =3D ()
>
> Of course, ordinary modules have no such constraint.=A0 Any thoughts a= s to
> what is going on here, and whether it can be fixed?=A0 This has really=
> restricted designs I've been using, forcing me to flatten out stru= ctures
> that are more naturally nested.
>
> y
>


--
Caml-list mailing list. =A0Subscription 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


--f46d043c7baacd304f04ad5aff35--