[Haskell-cafe] Why is $ right associative instead ofleftassociative?

John Hughes rjmh at cs.chalmers.se
Sun Feb 5 08:21:00 EST 2006

 > Quoting Paul Hudak <paul.hudak at yale.edu>:
 >> Actually, one of the main reasons that we chose (:) is that that's what
 >> Miranda used.  So, at the time at least, it was not entirely clear what
 >> the "de facto universal inter-language standard" was.

Phil Wadler argued for the ML convention at the time, and wrote a document
containing a fair amount of sample code to illustrate what it would look
like. We noticed something surprising: instead of (x:xs) and the like, Phil
had consistently written (x :: xs) -- note the extra spaces. Somehow, using
the longer operator name led him to feel spaces were needed around it. That
in turn made his lines longer, encouraged him to split definitions across
lines, and so on. When I read the thing, I realised after a while that I 
skipping all the code fragments -- because they just looked too big and
complicated to take in during a quick reading. It was at least partly that
experience that convinced us that using :: for cons would impose a small
cost, but a real one, on readability. It may seem trivial, but the sum of
many such decisions is significant. The story does illustrate the 
of actually trying out syntactic ideas and seeing how they play--one can be
surprised by the result.

 >> I don't think Haskell Prime should be about changing the look and
 >> feel of the language.

It's about consolidating the most important extensions into the standard,
isn't it? Changes that break existing code should be very, very well
motivated--if porting code to Haskell Prime is too difficult, people just
won't do it.


More information about the Haskell-Cafe mailing list