Tutorial by Examples

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 number that follows the associativity information describes in what order the operators are applied. It must always be between 0 and 9 inclusive. This is commonly referred to as how tightly the operator binds. For example, consider the following fixity declarations (in base) infixl 6 + infixl ...
infixr 5 ++ infixl 4 <*>, <*, *>, <**> infixl 8 `shift`, `rotate`, `shiftL`, `shiftR`, `rotateL`, `rotateR` infix 4 ==, /=, <, <=, >=, > infix ??

Page 1 of 1