From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id CC0F37EE51 for ; Mon, 20 May 2013 02:26:42 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of markus.mottl@gmail.com) identity=pra; client-ip=74.125.82.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="markus.mottl@gmail.com"; x-sender="markus.mottl@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of markus.mottl@gmail.com designates 74.125.82.180 as permitted sender) identity=mailfrom; client-ip=74.125.82.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="markus.mottl@gmail.com"; x-sender="markus.mottl@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-we0-f180.google.com) identity=helo; client-ip=74.125.82.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="markus.mottl@gmail.com"; x-sender="postmaster@mail-we0-f180.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmcCAH5tmVFKfVK0jWdsb2JhbABZgzivIZIadggWDgEBAQEHCwsJEgYkgh8BAQVAARQHEgsBAwwGBQsDCg0hIQEBEQEFAQoSBhMSh2gBAw8Mnk+MP4J9g1YKGScDCliIEAEFDIw+gSWBMgeDVAOVUoFmgSmKdIM+FimEUSCBNQ X-IPAS-Result: AmcCAH5tmVFKfVK0jWdsb2JhbABZgzivIZIadggWDgEBAQEHCwsJEgYkgh8BAQVAARQHEgsBAwwGBQsDCg0hIQEBEQEFAQoSBhMSh2gBAw8Mnk+MP4J9g1YKGScDCliIEAEFDIw+gSWBMgeDVAOVUoFmgSmKdIM+FimEUSCBNQ X-IronPort-AV: E=Sophos;i="4.87,704,1363129200"; d="scan'208";a="18128496" Received: from mail-we0-f180.google.com ([74.125.82.180]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 20 May 2013 02:26:28 +0200 Received: by mail-we0-f180.google.com with SMTP id u56so1191566wes.11 for ; Sun, 19 May 2013 17:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=+rsqH973qBpXWifAu7NM/ZwqlUKqQA7GJcsidh9Nrzo=; b=xiFNYecChDLFzA16LCjHh/xKC/QiQ6wCiiNmAsadAS/zPJYZyaotZTPzi5GfsjYKvS CNgjv/IBovMo6C9OAm35Q5PjZWRWAIi6glfuy8ZskjQ8OePOTukzbJnxbmwv1zyOigz6 BpAcnyuhyzQVi4kmJ7rf/jhb4RyN0WlKMBRB6PUBTGJhfJAlu7CgfGz+buTFzuoo+Obi ycwSEJdKWp8d0xgg/ar71wGOvqjL+mdnVLwBSpJDUtn43dhE0xoGlih4kC2KFWAboKMZ EGmAhUiHD2x8iiO2v+4R5+38I+07VUFSw4huvL+2DwnrP8+LbDI2XycX+iw4azOAnE+j 7FGA== MIME-Version: 1.0 X-Received: by 10.180.210.225 with SMTP id mx1mr8809444wic.15.1369009588344; Sun, 19 May 2013 17:26:28 -0700 (PDT) Received: by 10.194.16.70 with HTTP; Sun, 19 May 2013 17:26:28 -0700 (PDT) In-Reply-To: References: Date: Sun, 19 May 2013 20:26:28 -0400 Message-ID: From: Markus Mottl To: Philippe Wang Cc: OCaml List Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] First-class modules in functor bodies 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 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 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