caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Problems building a library, types go missing
Date: Thu, 1 Aug 2013 17:00:20 +0200	[thread overview]
Message-ID: <20130801150020.GB8825@frosties> (raw)
In-Reply-To: <87txjdiq62.fsf@kingston.cl.cam.ac.uk>

On Mon, Jul 29, 2013 at 12:03:33PM +0100, Leo White wrote:
> 
> 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

Can I use some "with type" syntax instead? Something like

module Functor = (IntFails with type IntFoo_t.T_t = Foo_t.T_t)

I'm trying to keep the files short and few so I don't have to edit
multiple files every time I change something. At least till the API
stabilizes.

MfG
	Goswin

      reply	other threads:[~2013-08-01 15:00 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
2013-08-01 15:00   ` Goswin von Brederlow [this message]

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=20130801150020.GB8825@frosties \
    --to=goswin-v-b@web.de \
    --cc=caml-list@inria.fr \
    /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).