From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q1MHZmOu010429 for ; Wed, 22 Feb 2012 18:35:48 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnsCAOcmRU9KfVI0imdsb2JhbABDhSibZ4hIAYhkCCIBAQEKCQ0ZBiOBcwEBAQMBEgIPHQEbEgsBAwELBgULDQ0dAgIhAQERAQUBChIGExIJB4dfCZpRCosmTIJxhS0/iHMCBQuIdFiDCwFaEQEMCoRhASoGBEoGBQsKCAMEgheBFgSCXZJbhxeEAIMWPYQDgVMJ X-IronPort-AV: E=Sophos;i="4.73,465,1325458800"; d="scan'208";a="145483885" Received: from mail-ww0-f52.google.com ([74.125.82.52]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 22 Feb 2012 18:35:42 +0100 Received: by wgbds10 with SMTP id ds10so291926wgb.9 for ; Wed, 22 Feb 2012 09:35:42 -0800 (PST) Received-SPF: pass (google.com: domain of agarwal1975@gmail.com designates 10.180.8.164 as permitted sender) client-ip=10.180.8.164; Authentication-Results: mr.google.com; spf=pass (google.com: domain of agarwal1975@gmail.com designates 10.180.8.164 as permitted sender) smtp.mail=agarwal1975@gmail.com; dkim=pass header.i=agarwal1975@gmail.com Received: from mr.google.com ([10.180.8.164]) by 10.180.8.164 with SMTP id s4mr37527164wia.6.1329932142486 (num_hops = 1); Wed, 22 Feb 2012 09:35:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Zt5H5glRSzNnOcU6wsC64CzEajIIHNSTz/rkJh79CW0=; b=gx/3b/o2qWbCTBr2oZDTOvpA5++PcOWxzSKRm+fCzAaz8qRPXRSAp0pBUA32YQQmdj 0FGIDCrcPpG93tqMAA5SFTHndHCn3rItfy/mtOK1J3ODGf6FinLqv9hX7fI6DZWI51LQ WsSCZWSxX9T1KQn8EewHVvg349ZPDUZaxx++M= Received: by 10.180.8.164 with SMTP id s4mr31002999wia.6.1329932142312; Wed, 22 Feb 2012 09:35:42 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.39.148 with HTTP; Wed, 22 Feb 2012 09:35:22 -0800 (PST) In-Reply-To: References: From: Ashish Agarwal Date: Wed, 22 Feb 2012 17:35:22 +0000 Message-ID: To: Till Varoquaux Cc: =?ISO-8859-2?Q?Milan_Stanojevi=E6?= , "Hezekiah M. Carty" , Caml List Content-Type: multipart/alternative; boundary=f46d0442807eeafc6804b990f4b4 Subject: Re: [Caml-list] Re: "module type of" on sub-module of functor result --f46d0442807eeafc6804b990f4b4 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Here's an example I still don't know how to accomplish: module Map =3D struct module Make (Ord : BatInterfaces.OrderedType) : sig include module type of BatMap.Make(Ord).Labels (* this line is invalid *) end =3D struct include BatMap.Make(Ord) include Labels end end The idea is I only want "module type of Labels" for the functor's output, but I need BatMap.Make(Ord) within the implementation (perhaps to implement some other functions). I thought I can simply replace the line "include BatMap.Make(Ord)" with "open BatMap.Make(Ord)", and then not provide the explicit signature. But "open BatMap.Make(Ord)" gives a syntax error. 2012/2/22 Till Varoquaux > 2012/2/22 Milan Stanojevi=C4=87 d > > On Tue, Feb 21, 2012 at 3:32 PM, Hezekiah M. Carty wrote: > >> On Tue, Feb 21, 2012 at 2:37 PM, Ashish Agarwal > 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 sampl= e. > >>> > > > > 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 > --f46d0442807eeafc6804b990f4b4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Here's an example I still don't know how to accomplish:

module Map =3D struct
=C2=A0 module Make (Ord : BatI= nterfaces.OrderedType) : sig
=C2=A0 =C2=A0 include module type of= BatMap.Make(Ord).Labels (* this line is invalid *)
=C2=A0 end =3D struct
=C2=A0 =C2=A0 include BatMap.Make(Ord)=
=C2=A0 =C2=A0 include Labels
=C2=A0 end
end<= /div>

The idea is I only want "module type of= Labels" for the functor's output, but I need BatMap.Make(Ord) wit= hin the implementation (perhaps to implement some other functions).

I thought I can simply replace the line "include B= atMap.Make(Ord)" with "open=C2=A0BatMap.Make(Ord)", and then= not provide the explicit signature. But "open=C2=A0BatMap.Make(Ord)&q= uot; gives a syntax error.


2012/2/22 Till Varoquaux <till@= pps.jussieu.fr>
2012/2/22 Milan Stanojevi=C4=87 <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 hit= ting 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&= quot;, line 6, characters 38-39:
>>> Error: Syntax error: 'end' expected
>>> File "a.ml&= quot;, 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 "inclu= de module type
> of"
>
> --
> Caml-list mailing list. =C2=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
>

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(*), =C2=A0[A(B)] and =C2=A0[A.B] are syntacticly valid module_expr&#= 39;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/manu= al019.html#module-expr

--f46d0442807eeafc6804b990f4b4--