[Haskell-cafe] Why are && and || right-associative?

David Feuer david.feuer at gmail.com
Fri Apr 12 02:29:12 UTC 2019

I don't know the historical answer, but I think it's because the true
fixity can't be expressed in Haskell. As far as I can tell, there's no
operator with the same precedence as && or || that can be meaningfully
combined with it. But if these operators were defined just "infix", then
we'd have to write junk like x || (y || z). So instead we picked a
direction out of a bag and never had a reason to look back.

On Thu, Apr 11, 2019, 10:13 PM Richard Eisenberg <rae at richarde.dev> wrote:

> Hi café,
> Why are && and || in the Prelude right-associative? This contradicts my
> expectation and the way these work in other languages. That said, I can't
> think of any harm in it. This came up from a question asked by a student,
> and I have no idea why the design is this way.
> Thanks,
> Richard
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20190411/ed197e96/attachment.html>

More information about the Haskell-Cafe mailing list