[Haskell-cafe] Re: Why is $ right associative instead ofleftassociative?

Ben Rudiak-Gould Benjamin.Rudiak-Gould at cl.cam.ac.uk
Sun Feb 5 13:50:57 EST 2006


Paul Hudak wrote:
> Minor point, perhaps, but I should mention that : is not special syntax 
> -- it is a perfectly valid infix constructor.

But Haskell 98 does treat it specially: you can't import Prelude hiding 
((:)), or rebind it locally, or refer to it as Prelude.:. In fact I've 
always wondered why it was done this way. Can anyone enlighten me? Of course 
it might be confusing if it were rebound locally, but no more confusing than 
the fact that [f x | x <- xs] is not the same as (map f xs).

It might be kind of nice if the list type were actually defined in the 
Prelude as

     data List a = Nil | a : List a

and all of the special [] syntax defined by a desugaring to this (entirely 
ordinary) datatype, e.g. [1,2] -> 1 Prelude.: 2 Prelude.: Prelude.Nil.

-- Ben



More information about the Haskell-Cafe mailing list