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 B162381799 for ; Mon, 29 Jul 2013 13:03:34 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of lpw25@cam.ac.uk) identity=pra; client-ip=131.111.8.132; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="lpw25@cam.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of lpw25@cam.ac.uk) identity=mailfrom; client-ip=131.111.8.132; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="lpw25@cam.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@ppsw-32.csi.cam.ac.uk) identity=helo; client-ip=131.111.8.132; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="postmaster@ppsw-32.csi.cam.ac.uk"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlYCAHlL9lGDbwiElGdsb2JhbABbgzu+J4EWFg4BAQEBBw0JCRQFI4IkAQEBAwEnEz8FCwshJQ8BBEkTh34DCQYMrwYiQogHjS6CTweEBwOZCJM4 X-IPAS-Result: AlYCAHlL9lGDbwiElGdsb2JhbABbgzu+J4EWFg4BAQEBBw0JCRQFI4IkAQEBAwEnEz8FCwshJQ8BBEkTh34DCQYMrwYiQogHjS6CTweEBwOZCJM4 X-IronPort-AV: E=Sophos;i="4.89,768,1367964000"; d="scan'208";a="27781796" Received: from ppsw-32.csi.cam.ac.uk ([131.111.8.132]) by mail2-smtp-roc.national.inria.fr with ESMTP; 29 Jul 2013 13:03:33 +0200 X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from kingston.cl.cam.ac.uk ([128.232.64.15]:43974) by ppsw-32.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.156]:587) with esmtpsa (PLAIN:lpw25) (TLSv1.2:DHE-RSA-AES128-SHA:128) id 1V3lEj-00076R-2k (Exim 4.80_167-5a66dd3) (return-path ); Mon, 29 Jul 2013 12:03:33 +0100 From: Leo White To: Goswin von Brederlow Cc: caml users References: <20130728001315.GA6534@frosties> X-Face: "XWxb[u_Z\PA_Y?9@|IA!!+jTb(/290-*ea/Un$I0B98.$n%eL.;2w*,z]WR#T:,p[ NBd++M7l]#7zj7!{~iw $W-"/=|dVjhT[D{4~gE}gK<2`.6fs!;uqqud]vs2N/3^m7{aS1V, Date: Mon, 29 Jul 2013 12:03:33 +0100 In-Reply-To: <20130728001315.GA6534@frosties> (Goswin von Brederlow's message of "Sun, 28 Jul 2013 02:13:15 +0200") Message-ID: <87txjdiq62.fsf@kingston.cl.cam.ac.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Caml-list] Problems building a library, types go missing If you look at the interfaces for works.ml and fails.ml (using "ocamlc -i"), you can see the problem: works.ml: module Foo : sig module T : sig type t = int val foo : t -> unit end end module Functor : sig module type Foo_t = sig type t val foo : t -> unit end module Make : functor (Foo : Foo_t) -> sig val do_foo : Foo.t -> unit end end fails.ml: module Foo : sig module T : sig type t = int val foo : t -> unit end end module Foo_t : sig module type T_t = sig type t val foo : t -> unit end end module Functor : sig module Make : functor (Foo : IntFoo_t.T_t) -> sig val do_foo : Foo.t -> unit end end As you can see the Fails.Functor.Make functor expects an argument with module type IntFoo_t.T_t, while the Works.Functor.Make functor expects an argument with module type Works.Functor.Foo_t. Since you hide IntFoo_t when compiling your tests, the compiler cannot find IntFoo_t.T_t and so it cannot check whether Fails.Functor.Make is being applied correctly. To fix this simply add a signature to Fails.Functor, or better yet add a "fails.mli" to your project: module Foo : sig module T : sig type t = int val foo : t -> unit end end module Foo_t : sig module type T_t = sig type t val foo : t -> unit end end module Functor : sig module Make : functor (Foo : Foo_t.T_t) -> sig val do_foo : Foo.t -> unit end end Regards, Leo Goswin von Brederlow writes: > Hi, > > I'm trying to build a library in one of 2 ways out of > seperate modules. All files are available via git from > > https://github.com/mrvn/ocam-problems/tree/functor-in-lib-problem > git clone git@github.com:mrvn/ocam-problems.git > > The first library works and uses these files: > > internal/IntFoo.ml : implement module T > internal/IntWorks.ml : declare module type T_t and functor taking a T_t > lib/works.ml : library mapping internal to external modules > test/test1.ml : test functor with local module > test/test2.ml : test functor with libraries module > test/test3.ml : test privatness of internal module (MUST FAIL) > test/test4.ml : test3 with too many includes (SHOULD FAIL) > > and the second fails and uses there files: > > internal/IntFoo_t.ml : declare module type T_t > internal/IntFoo.ml : implement module T > internal/IntFails.ml : functor taking a IntFoo_t.T_t > lib/fails.ml : library mapping internal to external modules > test/test5.ml : test functor with local module (FAILS) > test/test6.ml : test functor with libraries module (FAILS) > test/test7.ml : test privatness of internal module (MUST FAIL) > test/test8.ml : test7 with too many includes (SHOULD FAIL) > > > Now my question is: Why does the Fails.Foo_t.T_t type get lost all of > a sudden unless I include the internal directory in the search path? > > MfG > Goswin