From: "Daniel Bünzli" <daniel.buenzli@erratique.ch>
To: David Rajchenbach-Teller <David.Teller@ens-lyon.org>
Cc: OCaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Hiding private types
Date: Tue, 10 Feb 2009 19:14:42 +0100 [thread overview]
Message-ID: <ADF35143-FA88-4D8A-BB5C-BBEA4244A43D@erratique.ch> (raw)
In-Reply-To: <1234286066.6457.35.camel@Blefuscu>
Le 10 févr. 09 à 18:14, David Rajchenbach-Teller a écrit :
> Does anyone have an idea of how we could/should do this?
I already encoutered these kind of visilibility problems, I'm not sure
the following applies to your case but it's a case I managed to solve
(e.g. in react [1]).
Suppose you have two types Pack.a and Pack.b, and two submodule Pack.A
and Pack.B that define functions on the respective types. In these two
modules you also want to
have Pack.A.t = Pack.a and Pack.B.t = Pack.b so that the submodules
can be given to the usual functors.
The problem is then that when you use functions from Pack.A in the
toplevel you get values of type A.Pack.t = Pack.a but you would like
Pack.a to be printed. The solution is simple : in the mli of A and B
the signature of functions should use Pack.a and Pack.b, in other
words your signature should look like this :
module Pack = struct
type a
type b
module A : sig
type t = a
val create : unit -> a (* instead of unit -> t *)
end
module B : sig
type t = b
val create : unit -> b (* instead of unit -> t *)
end
end
This way you never get Pack.A.t and Pack.B.t in errors and in the
toplevel unless you request it by a type annotation (or use functors).
But I don't know if you can reorder your definitions to match this
pattern.
Best,
Daniel
[1] http://erratique.ch/software/react
prev parent reply other threads:[~2009-02-10 18:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-10 17:14 David Rajchenbach-Teller
2009-02-10 18:05 ` [Caml-list] " Martin Jambon
2009-02-10 18:24 ` David Rajchenbach-Teller
2009-02-10 18:14 ` Daniel Bünzli [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=ADF35143-FA88-4D8A-BB5C-BBEA4244A43D@erratique.ch \
--to=daniel.buenzli@erratique.ch \
--cc=David.Teller@ens-lyon.org \
--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