caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Module 'annotations' with separate module files.
@ 2011-03-10 18:36 Hans Ole Rafaelsen
  0 siblings, 0 replies; only message in thread
From: Hans Ole Rafaelsen @ 2011-03-10 18:36 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1302 bytes --]

Hi,

is there some way to put extra module annotations on modules when each
module is put in separate files. I want to have a private, friend an public
interface to my modules (discussed previously in this thread:
http://www.mail-archive.com/caml-list@yquem.inria.fr/msg06513.html

If I put it in one file, it seems to work:
module type MP = (* Signature of public module *)
sig
  type t
  val make_t : int -> t
  val public : t -> int
end

module type MF = (* Signature of 'friend' module *)
sig
  include MP
  val friend : t -> int
end

module T = (* Type of t *)
struct
  type t = int
end

module MI = (* Implementation *)
struct
  type t = T.t
  let make_t a = a
  let priv a = a + a
  let friend a = a + a
  let public a = a + a
end


module MP : MP = MI (* Public module *)
module MF : (MF with type t = T.t) = MI (* Friend module *)


module type F = (* Signatur of friend *)
sig
  val f1 : int -> int
  val f2 : int -> int
end


module F : F =
struct
  module M = MF
  let f1 a = a + (M.public (M.make_t a))
  let f2 a = a + (M.friend a)
end



let _ = F.f1 3
let _ = F.f2 3
let _ = MP.public (MP.make_t 10)

But I can not figure out how to put the signatures on MP and MF modules when
I put them in mP.ml and mF.ml. Do I need to put them inside nested structs
inside the files?

Thanks,

Hans

[-- Attachment #2: Type: text/html, Size: 1616 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-03-10 18:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-10 18:36 [Caml-list] Module 'annotations' with separate module files Hans Ole Rafaelsen

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).