+
+-- Check precedence of (arg op) or (op arg) respectively
+-- If arg is itself an operator application, its precedence should
+-- be higher than that of op
+checkSectionPrec left_or_right section op arg
+ = case arg of
+ OpApp _ op fix _ -> go_for_it (ppr_op op) fix
+ NegApp _ op -> go_for_it pp_prefix_minus negateFixity
+ other -> returnRn ()
+ where
+ HsVar op_name = op
+ go_for_it pp_arg_op arg_fix@(Fixity arg_prec _)
+ = lookupFixity op_name `thenRn` \ op_fix@(Fixity op_prec _) ->
+ checkRn (op_prec < arg_prec)
+ (sectionPrecErr (ppr_op op_name, op_fix) (pp_arg_op, arg_fix) section)