[Haskell-cafe] Specify array or list size?

Benjamin Franksen benjamin.franksen at bessy.de
Sat May 7 16:56:11 EDT 2005


On Saturday 07 May 2005 18:22, Sebastian Sylvan wrote:
> On 5/7/05, Daniel Carrera <dcarrera at digitaldistribution.com> wrote:
> > Hamilton Richards wrote:
> > > Well, for starters, lists and arrays are two entirely different topics.
> > > I've noticed that Haskell newbies sometimes confuse them --possibly the
> > > use of [] in list types and enumerations triggers an unconscious
> > > association with [] used in conventional languages for array indexing.
> >
> > I think it's because there's no real reason for someone to think that
> > the words "list" and "array" might not be synonims. I certainly don't
> > seen a linguistic distinction. Either term refers to an ordered
> > collection of items.
>
> Hmm. Not sure I agree. For me an "array" is a fixed set of elements
> which may or not contain stuff (not necessarily in a CS context but
> just linguistically). A "list" is more of a linear structure.
> An array is a sheet of paper with lines on it, a list is the todo-list
> written on that paper.
>
> Anyway. There is a difference, and I think the names reflect that pretty
> well.

I think that 'list' is a misnomer for what are actually (functional) stacks. 
That these so called lists are used for almost everything is due to (1) the 
nice syntactic sugar (2) the fact that there are many functions on lists in 
the standard libraries and (3) they can be infinite and thus act as streams.

It would be a great improvement if Haskell's standard library (including the 
Prelude) would provide a uniform framework for collections, and in particular 
sequences (linear collections, indexed by natural numbers), and there should 
be standard implementations that don't favour operations on the left end over 
those on the right end. It is a shame that a language like Haskell doesn't 
even have a Deque (double ended queue) in the its standard library.

Robert Will has proposed a new unified standard for collections (as well as 
some default implementations) with above properties (and a lot more). IMHO, 
his work is (at least) a very good starting point and deserves more 
attention.

Ben



More information about the Haskell-Cafe mailing list