From: "Ashish Agarwal" <agarwal1975@gmail.com>
To: "David Teller" <David.Teller@univ-orleans.fr>
Cc: "David Allsopp" <dra-news@metastack.com>,
Caml <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Invoking the standard library ?
Date: Tue, 29 Apr 2008 18:58:26 -0400 [thread overview]
Message-ID: <d8be5ae20804291558i7e5baa47ua2a228e165db0ff5@mail.gmail.com> (raw)
In-Reply-To: <1209498604.7286.43.camel@Blefuscu>
[-- Attachment #1: Type: text/plain, Size: 3073 bytes --]
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:
---- File lib2.ml ----
module String = String2
module List = List2
include Pervasives2 (* note Pervasives2 is "included" *)
---- File string2.ml ----
include String
let f1 = ...
let f2 = ...
---- File list2.ml ----
include List
let f1 = ...
let f2 = ...
---- File pervasives2.ml ----
include Pervasives
let identity x = x
let (<<-) f g x = f (g x)
let (->>) f g x = g (f x)
...
This solution has at least the following flaws:
- one has to write "open Lib2" in every other file
- the module names String2, List2, etc. are visible but we really don't want
them
On Tue, Apr 29, 2008 at 3:50 PM, David Teller <David.Teller@univ-orleans.fr>
wrote:
> 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:
> >
> > module String = struct
> > include String
> > (* Your functions here *)
> > 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
>
[-- Attachment #2: Type: text/html, Size: 4782 bytes --]
prev parent reply other threads:[~2008-04-29 22:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-29 14:26 David Teller
2008-04-29 18:19 ` [Caml-list] " Eric Cooper
2008-04-30 0:05 ` Jacques Garrigue
2008-04-30 7:51 ` Christophe Raffalli
2008-04-30 13:38 ` Eric Cooper
2008-05-01 1:59 ` Gordon Henriksen
2008-04-30 11:35 ` David Teller
[not found] ` <003a01c8aa2c$5962f6c0$017ca8c0@countertenor>
2008-04-29 19:50 ` David Teller
2008-04-29 22:58 ` Ashish Agarwal [this message]
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=d8be5ae20804291558i7e5baa47ua2a228e165db0ff5@mail.gmail.com \
--to=agarwal1975@gmail.com \
--cc=David.Teller@univ-orleans.fr \
--cc=caml-list@yquem.inria.fr \
--cc=dra-news@metastack.com \
/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