
On Sun, Feb 05, 2006 at 06:50:57PM +0000, Ben Rudiak-Gould wrote:
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.
it would probably be simpler just to declare [] to be a data constructor. that is what jhc does, it parses the same as any capitalized name. so you can do import Prelude hiding([]) data Foo a = [] | Foo | Bar and list syntax desugars into whatever (:) and [] are in scope. similarly, (x,y) is just sugar for (,) x y and (,) is a standard data constructor and can be hidden, redefined, etc just like any other one. John -- John Meacham - ⑆repetae.net⑆john⑈