Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Don Syme <dsyme@microsoft.com>
To: "'caml-list@inria.fr'" <caml-list@inria.fr>
Subject: RE: additions to standard library?
Date: Tue, 14 Mar 2000 09:24:16 -0800	[thread overview]
Message-ID: <39ADCF833E74D111A2D700805F1951EF180144F3@RED-MSG-06> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3723 bytes --]


I've often wondered why languages don't support "extensions" to library
namespaces (and perhaps even to functors).  e.g. one could define 

let String.explode s = ....
let String.implode s = ...
let myfun = ...

If you like you can consider this as a shorthand for the longwinded
declaration of a module and the rebinding of member names.  Since all the
typing mechanisms are "monotonic" w.r.t. adding new members to a module
(i.e. if a module matched a signature before it will continue to match after
an addition like the above) then this should make sense theoretically.   The
implementation can probably just whack in another element to the dictionary
structure that represents a module.  

The "signature" of a seperately compilation unit would probably have to
declare how the unit extends existing structures, functors and signatures,
e.g. the .mli for the above code might be: 

val String.explode : string -> char list
val String.implode : char list -> string
val myfun : int -> int

I put "signature" in quotes because the extensions are not part of signature
of the module defined by the unit itself (i.e. the rule "each compilation
unit introduces one new top level module" would be relaxed.

You then probably need a distinction between "open" and "load", i.e. open a
top level module namespace and load a compilation unit, and you probably
need to explicitly load any compilation units that define extensions (rather
than relying on the default behaviour of OCaml where a compilation unit is
"loaded" by virtue of using a module access, e.g. Myfile.myfun).  For
example:

(A) open Myfile  (* myfun now in scope *)

(B) load Myfile  (* String.explode, String.implode, Myfun.myfun now in
scope. *)
    open Myfile  (* myfile becomes available *)

(B) Myfile.myfile (* OK - but String.explode not available without an *)
                  (* explicit load *)

I think that with that distinction in place dependency analysis would be OK.
More ambitiously, perhaps one could even extend functors coherently in this
way, i.e. 

let Set.Make(Ord: OrderedType).set_exists = ...

Realistically you probably need a way of accessing the existing elements
generated by the application, which we could do by reusing my favourite
keyword "as".... e.g

let (Set.Make(Ord: OrderedType) as M).set_exists = ...
    try M.fold (fun x _ -> if p x then failwith "t") s (); false
    with Failure "t" -> true

This is all quite similar to the mechanisms I used for the module mechanism
in my theorem prover "Declare", which didn't have functors as such, but even
the basic mechanisms certainly did make the abstract algebra examples I did
look quite nice.

Don

P.S. I don't know if you could also add types to modules in this way?



-----Original Message-----
From: Jerome Vouillon [mailto:Jerome.Vouillon@inria.fr]
Sent: 13 March 2000 09:26
To: caml-redistribution@pauillac.inria.fr
Subject: Re: additions to standard library?


On Tue, Mar 07, 2000 at 04:24:00PM +0100, Markus Mottl wrote:
> What do you think about the idea to make use of the "usercontrib"
> CVS-repository at INRIA for such purposes? We could open a "stable" and
> "development" branch for standard libraries (and "otherlibs") there, where
> people could place and "peer review" their contributions. From time to
> time, the OCaml-team can peek at the additions and take what they consider
> useful.

I see two dangers:
- this could result in an over-featured library;
- the "regular" and the "extended" library may diverge.
On the other hand, I don't think it would be a bad thing if more
people contributed to the development of O'Caml.

Anyway, you can always set up a repository on Sourceforge or any
similar site and see what happens. :-)

-- Jérôme



             reply	other threads:[~2000-03-21 13:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-14 17:24 Don Syme [this message]
2000-03-21 21:08 ` John Max Skaller
  -- strict thread matches above, loose matches on Subject: below --
2000-03-21 21:43 Don Syme
2000-03-10 17:55 Manuel Fahndrich
2000-03-07 15:24 Markus Mottl
2000-03-08 19:03 ` Jean-Christophe Filliatre
2000-03-08 22:29   ` Markus Mottl
2000-03-10 10:51     ` Christian RINDERKNECHT
2000-03-09 13:18 ` Thorsten Ohl
2000-03-10 10:04   ` Francisco Valverde Albacete
2000-03-10 20:33     ` Markus Mottl
2000-03-14 23:15       ` Max Skaller
2000-03-11 18:49     ` Brian Rogoff
2000-03-12  1:54 ` Jerome Vouillon
     [not found]   ` <200003120239.DAA18581@miss.wu-wien.ac.at>
2000-03-14 17:53     ` Pierre Weis

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=39ADCF833E74D111A2D700805F1951EF180144F3@RED-MSG-06 \
    --to=dsyme@microsoft.com \
    --cc=caml-list@inria.fr \
    /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