From: Hans Ole Rafaelsen <hrafaelsen@gmail.com>
To: caml-list@inria.fr
Subject: [Caml-list] Module 'annotations' with separate module files.
Date: Thu, 10 Mar 2011 19:36:09 +0100 [thread overview]
Message-ID: <AANLkTikwTGpQ4-VRKH7wJSda1w4rGmR0ZcryUFGt6mWa@mail.gmail.com> (raw)
[-- 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 --]
reply other threads:[~2011-03-10 18:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=AANLkTikwTGpQ4-VRKH7wJSda1w4rGmR0ZcryUFGt6mWa@mail.gmail.com \
--to=hrafaelsen@gmail.com \
--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