
On 6/19/07, Andrew Coppin
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.
Um, not quite. Lists may be the most common data structure in a Haskell program, but they certainly aren't the *only* collection type. A quick tour through the Hierarchical Libraries[0] documentation finds: - Data.Map (more commonly known as 'dictionaries') - Data.HashTable (same idea, different runtime characteristics) - many varieties of Data.Array (fixed sized arrays, with quick access to any element) - Data.Sequence - Data.Set - .... The core language also offers tuples, which are a very interesting kind of collection, if very primitive. Also, tree structures are trivial to create that it is often easier to define the precise tree structure you want instead of reusing one of a dozen possible modules. Here's one that's common in many tutorials: data Tree a = Leaf a | Branch (Tree a) (Tree a) deriving (Show, Eq) These are just some of the purely functional data structures[1] that provide collection types within a Haskell program. -- Adam [0]: http://www.haskell.org/ghc/docs/latest/html/libraries/index.html [1]: http://www.google.com/search?q=purely+functional+data+structures