From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA04461; Tue, 14 Jan 2003 22:06:43 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA04543 for caml-list@pauillac.inria.fr; Tue, 14 Jan 2003 22:06:42 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA01902 for ; Tue, 14 Jan 2003 20:15:03 +0100 (MET) Received: from wptx49.physik.uni-wuerzburg.de (wptx49.physik.uni-wuerzburg.de [132.187.40.49]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h0EJF2v10404 for ; Tue, 14 Jan 2003 20:15:02 +0100 (MET) Received: from wptx47.physik.uni-wuerzburg.de (wptx47.physik.uni-wuerzburg.de [132.187.40.47]) by wptx49.physik.uni-wuerzburg.de (8.10.0/8.10.0.Beta6) with ESMTP id h0EJEx507332; Tue, 14 Jan 2003 20:14:59 +0100 (MET) Received: (from ohl@localhost) by wptx47.physik.uni-wuerzburg.de (8.10.0.Beta12/8.10.0.Beta12) id h0EJExL28392; Tue, 14 Jan 2003 20:14:59 +0100 From: Thorsten Ohl MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15908.25011.52235.354636@wptx47.physik.uni-wuerzburg.de> Date: Tue, 14 Jan 2003 20:14:59 +0100 To: caml-list@inria.fr Cc: Julien.Signoles@lri.fr Subject: [Caml-list] Legality of using module types from .mli in .ml X-Mailer: VM 6.84 under Emacs 20.7.1 Reply-To: ohl@physik.uni-wuerzburg.de Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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