Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
RE: additions to standard library?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-03-10 (18:48)
From: Manuel Fahndrich <maf@m...>
Subject: RE: additions to standard library?

The issue you are raising is a good one. SML/NJ can handle some of it,
because the semantics of "open" are different there. Once can actually say:

	module Foo = struct
        open B

and obtain a copy of B within Foo.

This might even work to extend functors as in:

	functor Foo(Arg : A) =
           module B = Bar(A)
           open B
           let extensions = ...

However, this interpretation of "open" has impacts on compilation
dependencies, in particular scoping analysis (See e.g.  "Dependency analysis
for Standard ML; Matthias Blume; ACM Trans. Program. Lang. Syst. 21, 4 (Jul.
1999), Pages 790 - 812").


-----Original Message-----
From: Markus Mottl []
Sent: Friday, March 10, 2000 12:04 AM
Subject: Re: additions to standard library?

> But  when  using functorial  interfaces  like  Set.Make,  you have  to
> redefine these  functions for each  application of the  functor. Thus,
> you  really need these  functions to  be defined  in the  functor i.e.
> together with the datatype (and, by the way, you can then define these
> functions a bit more efficiently---without using exceptions).

Exactly - this raises another question which has been bothering me from
time to time when using the module system:

How can you extend the functionality of a module without having to "copy"
the definitions of the underlying module "by hand"? In a case which I found
particularly ugly (in the "res"-library), I had to "copy" nearly 100 lines
as in:

  module Foo = struct
    module B = ...
    type t = B.t
    let iter = B.iter
    let iteri = B.iteri
    let map =
    let mapi = B.mapi

Everytime the other module gets extended, I have to add code by hand here,
too, to make it available. I do not see any simple workaround for this.
Extending standard libraries with needed functionality would be much easier
if there were a convenient way to get around the problem above.

Markus Mottl

Markus Mottl,,