After various attempts at this problem a couple months ago, I settled for the following (not ideal) solution. I suffix all modules I am extending with a 2. Then I package them up in a module named Lib2, which is defined such that doing "open Lib2" serves as a drop-in replacement for the Standard Library. As follows:
On Tue, 2008-04-29 at 20:07 +0100, David Allsopp wrote:
> I don't quite following the motivation for needing module Inria: there's no
> problem with writing:
>> (* Your functions here *)
> module String = struct
> include String
> end
Doesn't work whenever the module is contained in its own file.
(*File string.ml*)
include String
let _ = print_endline "Done"
(*end of file string.ml*)
$ ocamlbuild string.cmo
Circular build detected
(string.cmi already seen in [ string.cmi; string.cmo ])
Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.
$ ocamldep string.ml
string.cmo: string.cmo
string.cmx: string.cmx
$ ocamlc string.ml
File "string.ml", line 1, characters 8-14:
Unbound module String
etc.
> but I think perhaps I've not understood the problem properly. That said, why
> is defining module Inria clumsy? I copied the table of contents from the
> StdLib page and with a couple of %s instructions got
>
> module Inria =
> struct
> module Arg = Arg
> module Array = Array
> (* 34 additional lines *)
> module StringLabels = StringLabels
> module Sys = Sys
> end
>
> Which is exactly what you want, right?
Auto-generating the module is not hard. It's getting everything to
compile without having to hand-write a Makefile (e.g. with ocamlbuild).
Indeed, module Inria depends on [the original] String, [the original]
Sys, etc... and I wouldn't want ocamlbuild or ocamldep to decide
compiling string.ml before inria.ml.
Cheers,
David
--
David Teller
Security of Distributed Systems
http://www.univ-orleans.fr/lifo/Members/David.Teller
Angry researcher: French Universities need reforms, but the LRU act
brings liquidations.
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs