From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=AWL,HTML_MESSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 46552BBC1 for ; Wed, 30 Apr 2008 00:58:29 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkACAJpEF0hA6bjld2dsb2JhbACCNjWOYwEMBQIECQ8FlS+FYA X-IronPort-AV: E=Sophos;i="4.25,724,1199660400"; d="scan'208";a="25673594" Received: from wr-out-0506.google.com ([64.233.184.229]) by mail4-smtp-sop.national.inria.fr with ESMTP; 30 Apr 2008 00:58:28 +0200 Received: by wr-out-0506.google.com with SMTP id c30so264685wra.21 for ; Tue, 29 Apr 2008 15:58:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=6NPLv+ZRwKBSp0wuBEN30JISMvJ3lrsX465ziZYGxjM=; b=lBGob9vk+kcRzjRkKpihyHt5qvdQ1hgwR6MgxxxGMMFc0bI4+BON+E8LzD8/N+bLPnx3krpKryvHUzdB+c2POo4Y4eEhlIhkXk2C6nSEd7j2xnwHAzE3hNU4zjpZ6Rb1vtjBkiW+TDP4/rOweLg68UsbE7xnHOBt8KztRSSyXSQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=OTQNwRVZr4SAAZcLxjH2SEBVXD3XVrVtVPhpN3ie1tIH5dtX1OwgBEa3N3snaZ6wcjI/XYQJW3n/WuQ68stN2dT3vsOukqrBpEH7FKM2AWpoCN26TrbQ4AJuCjFGTToy5ir3TesyBhhIFrAVRSVTwPDOd9SCWFzca2CFyKMivaM= Received: by 10.141.178.5 with SMTP id f5mr9180rvp.91.1209509906025; Tue, 29 Apr 2008 15:58:26 -0700 (PDT) Received: by 10.141.41.9 with HTTP; Tue, 29 Apr 2008 15:58:26 -0700 (PDT) Message-ID: Date: Tue, 29 Apr 2008 18:58:26 -0400 From: "Ashish Agarwal" To: "David Teller" Subject: Re: [Caml-list] Invoking the standard library ? Cc: "David Allsopp" , Caml In-Reply-To: <1209498604.7286.43.camel@Blefuscu> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_15252_23423872.1209509906026" References: <1209479205.11285.15.camel@Blefuscu> <003a01c8aa2c$5962f6c0$017ca8c0@countertenor> <1209498604.7286.43.camel@Blefuscu> X-Spam: no; 0.00; lib:01 lib:01 pervasives:01 pervasives:01 univ-orleans:01 0100,:01 struct:01 endline:01 cmo:01 cmi:01 cmi:01 cmo:01 compilation:01 ocamldep:01 cmx:01 ------=_Part_15252_23423872.1209509906026 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 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 > ------=_Part_15252_23423872.1209509906026 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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

------=_Part_15252_23423872.1209509906026--