caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Leo White <lpw25@cam.ac.uk>
To: Goswin von Brederlow <goswin-v-b@web.de>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Problems building a library, types go missing
Date: Mon, 29 Jul 2013 12:03:33 +0100	[thread overview]
Message-ID: <87txjdiq62.fsf@kingston.cl.cam.ac.uk> (raw)
In-Reply-To: <20130728001315.GA6534@frosties> (Goswin von Brederlow's message of "Sun, 28 Jul 2013 02:13:15 +0200")


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 <goswin-v-b@web.de> 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

  reply	other threads:[~2013-07-29 11:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-28  0:13 Goswin von Brederlow
2013-07-29 11:03 ` Leo White [this message]
2013-08-01 15:00   ` Goswin von Brederlow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87txjdiq62.fsf@kingston.cl.cam.ac.uk \
    --to=lpw25@cam.ac.uk \
    --cc=caml-list@inria.fr \
    --cc=goswin-v-b@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).