From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id BDCA5BC57 for ; Mon, 24 May 2010 00:02:56 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlYCALdC+UvZSMDdi2dsb2JhbACRfYwUFQEBAQoLCgcPBR+8EoUTBA X-IronPort-AV: E=Sophos;i="4.53,286,1272837600"; d="scan'208";a="63315023" Received: from fmmailgate01.web.de ([217.72.192.221]) by mail4-smtp-sop.national.inria.fr with ESMTP; 24 May 2010 00:02:56 +0200 Received: from smtp06.web.de ( [172.20.5.172]) by fmmailgate01.web.de (Postfix) with ESMTP id BE81015B346FD for ; Mon, 24 May 2010 00:02:55 +0200 (CEST) Received: from [78.43.204.177] (helo=frosties.localdomain) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #4) id 1OGJG3-0006Lu-00 for caml-list@inria.fr; Mon, 24 May 2010 00:02:55 +0200 Received: from mrvn by frosties.localdomain with local (Exim 4.71) (envelope-from ) id 1OGJG9-0004VQ-VJ for caml-list@inria.fr; Mon, 24 May 2010 00:03:02 +0200 From: Goswin von Brederlow To: caml-list@inria.fr Subject: RFH: Values do not match: val bar1 : Foo.foo_t is not included in val bar1 : Foo.foo_t Date: Mon, 24 May 2010 00:03:01 +0200 Message-ID: <87632el1ii.fsf@frosties.localdomain> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX1+Is+e4J4bMEPBlsTyRF68PZfvs/eguWuW1rf6D w+XOyT1PfmZiyaNAXQD5R4yrCXT1Jx4kVFZGq3M5F8C8b0eq/O MnwqvRjj4= X-Spam: no; 0.00; val:01 foo:01 foo:01 val:01 cmx:01 mli:01 sig:01 extern:01 sig:01 intern:01 homeip:01 makefile:01 ocamlopt:01 -for-pack:01 ocamlopt:01 Hi, I'm playing around with packs and ways to avoid having to duplicate module signatures all over the place. So I came up with the following idea: Each module declares an external and internal module type and restricts itself to the internal type. The pack then further restricts the module to the external type. But then I get a type error I can't make heads or tails of: File "pack.cmx", line 1, characters 0-1: Error: The implementation (obtained by packing) does not match the interface pack.mli: Modules do not match: sig module type Extern = sig val bar1 : Foo.foo_t end module type Intern = sig val bar1 : Foo.foo_t val bar2 : Foo.foo_t end module I : sig val bar1 : Foo.foo_t val bar2 : Foo.foo_t end val bar1 : Foo.foo_t val bar2 : Foo.foo_t end is not included in sig val bar1 : Foo.foo_t end Values do not match: val bar1 : Foo.foo_t is not included in val bar1 : Foo.foo_t make: *** [all] Error 2 Can anyone explain that to me? MfG Goswin -- Here is a simple example that gives the above error: (also on http://mrvn.homeip.net/t/) ---------------[ Makefile ]--------------- all: ocamlopt -for-pack Pack -c foo.ml ocamlopt -for-pack Pack -c bar.ml ocamlopt -c pack.mli ocamlopt -pack -o pack.cmx foo.cmx bar.cmx clean: rm -f *.o *.cmx *.cmi *~ ---------------[ bar.ml ]--------------- module type Extern = sig val bar1 : Foo.foo_t end module type Intern = sig include Extern val bar2 : Foo.foo_t end module I : Intern = struct let bar1 = Foo.foo2 let bar2 = Foo.BAZ let bar3 = Foo.BLUB end include I ---------------[ foo.ml ]--------------- module type Extern = sig type foo_t = FOO | BAR | BAZ | BLUB val foo1 : foo_t end module type Intern = sig include Extern val foo2 : foo_t end module I : Intern = struct type foo_t = FOO | BAR | BAZ | BLUB let foo1 = FOO let foo2 = BAR let foo3 = BLUB end include I ---------------[ pack.mli ]--------------- module Foo : sig include Foo.Extern end module Bar : sig include Bar.Extern end -----------------------------------