Authoritative source: Operators and precedence

Operators and precedence

Expression fixity

User-defined operators declare associativity and precedence:

infixl 6 (+);
infixr 5 (++);
infix 4 (==);

Precedence is 0–9, higher binding more tightly. Application and projection bind more tightly than prefix operators; prefix operators bind more tightly than infix operators. Published custom operators should always declare fixity.

Type precedence

From loosest to tightest:

Level Forms
1 forall, exists
2 -> (right associative)
3 +
4 *
5 application, projection, parentheses

Examples:

A -> B -> C          // A -> (B -> C)
A + B * C            // A + (B * C)
Maybe(Int) -> String // application before arrow

Parentheses are encouraged whenever a mixed expression would make the intended grouping non-obvious.