infixl
vs infixr
vs infix
describe on which sides the parens will be grouped. For example, consider the following fixity declarations (in base)
infixl 6 -
infixr 5 :
infix 4 ==
The infixl
tells us that -
has left associativity, which means that 1 - 2 - 3 - 4
gets parsed as
((1 - 2) - 3) - 4
The infixr
tells us that :
has right associativity, which means that 1 : 2 : 3 : []
gets parsed as
1 : (2 : (3 : []))
The infix
tells us that ==
cannot be used without us including parenthesis, which means that True == False == True
is a syntax error. On the other hand, True == (False == True)
or (True == False) == True
are fine.
Operators without an explicit fixity declaration are infixl 9
.