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 p8K80mcs013701 for ; Tue, 20 Sep 2011 10:00:48 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvgBANlHeE7RVdQzkGdsb2JhbABCmR2OHggUAQEBAQkJDQcUBCGBUwEBAQEDEgIsARseAwwGBQsNLiEBAREBBQEcGSKfIgqLQYJchUE7iG0CAwaGcwSTS4oSgnE9g3A X-IronPort-AV: E=Sophos;i="4.68,410,1312149600"; d="scan'208";a="109684947" 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:00:42 +0200 Received: by vws20 with SMTP id 20so535128vws.10 for ; Tue, 20 Sep 2011 01:00:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=Vne+aqV25ScSrVNFAQlkcf05tDKxl0T427KC9o4moGA=; b=OkiWLfva0UHZVEolSeZNc152cI+rm0QIvhlq/4uf1ERGe3Uh5Aon40b1NUNH6ydHix KRo/J+WUY0qbdPM9Unn0Y/+3u4ARLyKO60stXsRHg15W3GkViinVKYCZ1E0ZnOULhFFD /ayRGxBFYQoipq0y2eJuEe6GEYFIbC9Cbasew= MIME-Version: 1.0 Received: by 10.52.29.42 with SMTP id g10mr400535vdh.36.1316505641686; Tue, 20 Sep 2011 01:00:41 -0700 (PDT) Received: by 10.52.109.7 with HTTP; Tue, 20 Sep 2011 01:00:41 -0700 (PDT) In-Reply-To: References: Date: Tue, 20 Sep 2011 10:00:41 +0200 Message-ID: From: Jacques Le Normand To: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p8K80mcs013701 Subject: Re: [Caml-list] A limitation of "with type" declarations for first-class modules 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 >