[Haskell-beginners] Question on (x:xs) form
Brandon Allbery
allbery.b at gmail.com
Mon Dec 23 15:03:26 UTC 2013
On Mon, Dec 23, 2013 at 9:57 AM, Angus Comber <anguscomber at gmail.com> wrote:
> Why are the brackets required? And what do they signify?
> Eg reverse' x:xs = reverse' xs ++ [x] results in a parse error.
>
If you leave them off then it's parsed as three parameters instead of a
pattern as a single parameter. But that also leads to a parse error since
you can't use a bare operator that way. Which is "weird", but you can get
into inconsistent parses if you try to guess that the parentheses are
needed: should it be `(x:xs)` a pattern, or should it be `x (:) xs` 3
patterns with an infix constructor as the second?
--
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20131223/b6ea37b1/attachment.html>
More information about the Beginners
mailing list