[Haskell-cafe] Collections

Jens Fisseler Jens.Fisseler at FernUni-Hagen.de
Tue Jun 19 15:38:38 EDT 2007

On Tue, 19 Jun 2007, Andrew Coppin wrote:

> In Smalltalk, there is a wide selection of collection types, all with
> different facilities and efficiency trade offs. There is bag, set, list,
> array, ordered list, dictionary, hash table, weak array, etc. A whole
> menagerie of collection types.
> However, Haskell only has 1 type of collection: linked lists. (And only
> single-linked at that.) While other "normal" programming languages spend huge
> amounts of effort trying to select exactly the right collection type for the
> task in hand, Haskell programs only ever use linked lists.

Most Haskell programs use other data structures than lists.

Writing Haskell programs doesn't automagically change the the behaviour of 
linked list into the collection type you need. Have you looked at the 
Haskell standard library? There are quite many collection types available: 
sets, maps, hash tables, queues, graphs, you name it.

Note that most collection types are not built into the language itself, 
but are part of the standard library, i.e. the STL in case of C++, the 
Java standard library, and I presume it is the same with Smalltalk.

The equivalent of Haskell's list data type would be the array type of most 
imperative or object-oriented languages. Both are some sort of basic 
collection type, good for their own sake, but if you want more 
specialized collection types, you have to implement them.



More information about the Haskell-Cafe mailing list