infix order p, q where
tighter than a, b
associate left c, d
looser than e, f
infix order p, q where { tighter than a, b; associate left c, d; looser than e, f; }
infix order u -- no fixity at all; disconnected from all other operators
Multiple (non-conflicting) fixity declarations can occur in the same module, even for the same operators. (Allow duplicates?)
Conflicting declarations are disallowed:
- Anything that directly introduces a cycle is obviously nonsense.
- Anything that associates with other operators must associate in a consistent manner. (If
c
andd
already associate right, then the example above is disallowed.)
Orphan declarations are disallowed: p
and q
must be defined in the current module. (Allow this to be turned off with a pragma?)
Order-inducing declarations are disallowed: this is to prevent cycles from occurred when two otherwise non-conflicting modules are used together. A fixity declaration is order-inducing if the declaration transitively induces an additional ordering between operators not defined in the current module. For example, if a
and f
are operators from another module and in those modules a
binds neither tighter nor looser than f
, then the fixity declaration above is disallowed as it would imply that a
binds looser than f
. This prevents the situation where another module transitively induces the opposite ordering, leading to a cycle. (Allow this to be turned off with a pragma?)
For compatibility with existing code, numeric fixity declarations are implicitly embedded into this ordering scheme by the compiler. The ordering for operators with numeric precedences is imposed on all other operators with a numeric precedence, including those not in the current scope and those that have not even been encountered by the compiler.
An operator is permitted to have both a numeric precedence and a poset fixity declaration as long as they do not conflict (again for backward compatibility).