[Haskell-cafe] List syntax -- [] vs ()

Crypt Master cryptmaster at hotmail.com
Sat Jul 3 05:12:25 EDT 2004


I have noticed that lists seem to swtich between using [] and using (). for 

listSum [] = 0
listSum (x:xs) = x + listsum xs

but when specificy lists you use [] as in [1,2,3].

or type signatures are [a] -> [a]

It also seems when they mentioned on the right hand side it also always [].

Is it just for pattern matching that you use the "tuple" syntax ? How does 
haskell know we dont mean a tuple ? Or do we mean a tuple when we say (x:xs) 


MSN 8 with e-mail virus protection service: 2 months FREE* 

More information about the Haskell-Cafe mailing list