[Haskell-beginners] Question on (x:xs) form

Christian Maeder Christian.Maeder at dfki.de
Thu Jan 2 14:54:36 UTC 2014


Am 23.12.2013 15:57, schrieb Angus Comber:
> Why are the brackets required?  And what do they signify?
>
> Eg reverse' x:xs = reverse' xs ++ [x] results in a parse error.

I just want to add that "prefix application"/juxtaposition binds 
stronger than "infix application" and that therefore spaces should be 
put around infix symbols (like ":") to stress this fact:

     reverse x:xs
is the same as
     reverse x : xs
and both are parsed as
     (reverse x) : xs
which is different from
     reverse (x : xs)
although "x:xs" almost looks like "(x:xs)"

Cheers Christian



More information about the Beginners mailing list