From: Thorsten Ohl <ohl@physik.uni-wuerzburg.de>
To: caml-list@inria.fr
Cc: Julien.Signoles@lri.fr
Subject: [Caml-list] Legality of using module types from .mli in .ml
Date: Tue, 14 Jan 2003 20:14:59 +0100 [thread overview]
Message-ID: <15908.25011.52235.354636@wptx47.physik.uni-wuerzburg.de> (raw)
I'm often referring to module types defined in an interface file in
order to reduce redundancy. For example
$ cat a.mli
module type T = sig val n : int end
module M : T
$ cat a.ml
module type T = A.T
module M : T = struct let n = 42 end
where T can be rather long. Is this legal? The manual says in
section 6.12
A compilation unit behaves roughly as the module definition
module unit-name : sig unit-interface end = struct unit-implementation end
and refrains from defining `roughly' :-). I came up with conflicting
evidence:
O'Caml accepts it
$ ocamlopt a.mli a.ml
However, it is not equivalent to
module B :
sig
module type T = sig val n : int end
end =
struct
module type T = B.T
module M = struct let n = 42 end
end
which is obviously rejected by O'Caml, since B.T is not bound. The
pair (a.mli, a.ml) more closely resembles
module Aux_C =
struct
module type T = sig val n : int end
end
module type C =
sig
module type T = Aux_C.T
module M : T
end
module C : C =
struct
module type T = Aux_C.T
module M = struct let n = 42 end
end
without binding Aux.T. My question is now: is the pair (a.mli, a.ml)
intentionally legal or do I need to expand the reference A.T, as in
$ cat pedantic_a.mli
module type T = sig val n : int end
module M : T
$ cat pedantic_a.ml
module type T = sig val n : int end
module M : T = struct let n = 42 end
because I've have taken advantage of a bug in the compiler.
The reason I'm asking this, is that my shorthand [as in (a.mli, aml)]
breaks Julien Signoles' defunctorizer.
Cheers,
-Thorsten
--
Thorsten Ohl, Physics Dept., Wuerzburg Univ. -- ohl@physik.uni-wuerzburg.de
http://theorie.physik.uni-wuerzburg.de/~ohl/ [<=== PGP public key here]
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next reply other threads:[~2003-01-14 21:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-14 19:14 Thorsten Ohl [this message]
2003-01-15 16:28 ` [Caml-list] " Julien Signoles
2003-01-15 16:59 ` Thorsten Ohl
2003-01-15 17:37 ` Julien Signoles
2003-01-15 21:57 ` David Brown
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=15908.25011.52235.354636@wptx47.physik.uni-wuerzburg.de \
--to=ohl@physik.uni-wuerzburg.de \
--cc=Julien.Signoles@lri.fr \
--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