Version française
Home     About     Download     Resources     Contact us    
Browse thread
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: -- (:)
From: Thorsten Ohl <ohl@h...>
Subject: additions to standard library?
Markus Mottl <mottl@miss.wu-wien.ac.at> writes:

> Hello, it sometimes happens that I need functions on abstract data
            ^^^^^^^^^ often :-)
> types in the standard library which are not available there, but
> could be considered as "usual" operations on such data.

> Some specific examples include, e.g.:

My favorites are Map and List, of which I keep carrying around
turbocharged versions.

> CVS-repository [...] "peer review"

That's a brilliant idea!

Here's another issue in the same problem domain, that might be more
interesting for developers: wouldn't it be possible to add a language
feature that allows to extend module implementations without opening
the pandora box of classes with inheritance?

Currently, we can use `include' to extend module types, but not
implementations.  I'm thinking of something like

    module type ThoList =
      sig
    	include List  (* doesn't work because list.mli is a file,
                         but you get the idea :-) *)
    	val flatmap : ('a -> 'b list) -> 'a list -> 'b list
      end
    
    module ThoList : ThoList=
      sig
    	include List
    	let rec flatmap f = function
    	  | [] -> []
    	  | x :: rest -> f x @ flatmap f rest
      end
 
Cheers,
-Thorsten
-- 
Thorsten Ohl, Physics Department, TU Darmstadt -- ohl@hep.tu-darmstadt.de
http://heplix.ikp.physik.tu-darmstadt.de/~ohl/ [<=== PGP public key here]