On Tue, 27 Apr 1999, Hans Aberg wrote:
> Then Haskell uses this to implement sets and maps by using C++ STL style
> balanced trees. As Haskell already has generic variables, just as in the
> case of lists, it needs only be implemented once.
As just a general comment, from my usage of the STL it has two advantages
over C++ code I write (neglecting the obvious one that code written by
other people is always more reliable than the code I write myself :-()
(1) It dramatically simplifies memory allocation/deallocation & also
copying before modifying one of the resulting copies. These things are
never an issue in a functional language.
(2) It provides algorithms which work on any data structure which supports
any notions fundamental to the algorithm, e.g., ordering, etc. So for
example I can prototype using vector's everywhere and, when I discover
that they're taking up too much memory and that I never actually use the
random access facility I can swap them for lists and everything still
works.
For me what would make an STL-like library useful would be having
collections of algorithms available which operate on any `bulk type' for
which they make sense, but I suspect that to be suitably efficient
handwritten versions would be needed for each type. (Folding over sets vs
folding over lists vs folding over bags ..., etc). It might also make the
error messages for some prelude functions, e.g., map, more slightly
more vague:
`Int' is not an instance of MappableContainer a'
___cheers,_dave______________________________________________________
email: [EMAIL PROTECTED] "Someday, even toasters will have
www.cs.bris.ac.uk/~tweed/pi.htm monads in them thanks to Haskell."
work tel: (0117) 954-5253 M P Jones (allegedly)