From: Dawid Toton <d0@wp.pl>
To: Caml <caml-list@inria.fr>
Subject: [Caml-list] When functor yields many types - include a module with extra type equality?
Date: Tue, 03 Apr 2012 13:23:27 +0200 [thread overview]
Message-ID: <4F7ADDAF.2030201@wp.pl> (raw)
Consider the following:
--- a.mli
module type B = sig
type t
end
module type S = sig
type t
type other_lenghty_definitions
val not_much_code : t
end
module Make (B : B) : S
with type t = B.t
---
--- a.ml
module type B = sig
type t
end
module type S = sig
type t
type other_lenghty_definitions
val not_much_code : t
end
module Make (B : B) = struct
type t = B.t
type other_lenghty_definitions
let not_much_code = assert false
end
---
So we have to keep 3 copies of other_lenghty_definitions. I can have it
isolated in a separate file and insert into a.ml and a.mli in an extra
preprocessing step. But I believe there should be some clean solution,
something like the following:
--- c_sig.ml
module S = struct
type t
type other_lenghty_definitions
end
module type S = sig
include (module type of S) (* 1 *)
val not_much_code : t
end
---
--- c.mli
module type B = sig
type t
end
module Make (B : B) : C_sig.S
with type t = B.t
---
--- c.ml
module type B = sig
type t
end
module Make (B : B) = struct
include C_sig.S
with type t = B.t (* 2 *)
let not_much_code = assert false
end
---
How to do what I mark with (* 1 *) and (* 2 *) correctly? Would it help
if I upgrade my toolchain from 3.11.2 to some more recent version?
Dawid
next reply other threads:[~2012-04-03 11:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-03 11:23 Dawid Toton [this message]
2012-04-03 12:40 ` Gabriel Scherer
2012-04-03 17:54 ` Hezekiah M. Carty
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=4F7ADDAF.2030201@wp.pl \
--to=d0@wp.pl \
--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