[Haskell-beginners] [x] and (x:_) for lists -- did you ever think that odd?
Brandon Allbery
allbery.b at gmail.com
Sun May 20 23:33:38 CEST 2012
On Sun, May 20, 2012 at 5:14 PM, AntC <anthony_clayden at clear.net.nz> wrote:
> Would this pattern matching seem less odd?:
>
> head [x ..] = x
> length [x, xs at ..] = 1 + length xs
>
>
> Experienced Haskellers need not answer: you've got too used to ( : ) ;-)
>
You missed experienced Lispers, who are likewise entirely comfortable with
cons-like notation.
I would want to very carefully check the implications of your suggestion:
it might not integrate well with the rest of pattern matching syntax, in
particular some uses of it might turn out to be impossible to distinguish
from existing constructs. Some parts of Haskell's syntax are rather, how
shall I put it? tightly reasoned, with less room for expansion than is
immediately obvious.
(Please note, I am not trying to say "don't bother", I am saying that the
syntax questions really are tricky and you need to work carefully. This
syntax might end up being fine, or it might need to be worked somewhat
differently.)
--
brandon s allbery allbery.b at gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120520/246d2e57/attachment.htm>
More information about the Beginners
mailing list