+ (con_left_assoc, con_right_assoc) = isLRAssoc fixs_assoc dc_nm
+
+ {-
+ c.f. Figure 16 and 17 in Haskell 1.1 report
+ -}
+ paren_prec_limit
+ | not is_infix = fromInt maxPrecedence + 1
+ | otherwise = getFixity fixs_assoc dc_nm + 1
+
+\end{code}
+
+\begin{code}
+getLRPrecs :: Bool -> Fixities -> Name -> [Integer]
+getLRPrecs is_infix fixs_assoc nm = [lp, rp]
+ where
+ {-
+ Figuring out the fixities of the arguments to a constructor,
+ cf. Figures 16-18 in Haskell 1.1 report.
+ -}
+ (con_left_assoc, con_right_assoc) = isLRAssoc fixs_assoc nm
+ paren_con_prec = getFixity fixs_assoc nm
+ maxPrec = fromInt maxPrecedence
+
+ lp
+ | not is_infix = maxPrec + 1
+ | con_left_assoc = paren_con_prec
+ | otherwise = paren_con_prec + 1
+
+ rp
+ | not is_infix = maxPrec + 1
+ | con_right_assoc = paren_con_prec
+ | otherwise = paren_con_prec + 1
+
+getFixity :: Fixities -> Name -> Integer
+getFixity fixs_assoc nm =
+ case lookupFixity fixs_assoc nm of
+ Fixity x _ -> fromInt x
+
+isLRAssoc :: Fixities -> Name -> (Bool, Bool)
+isLRAssoc fixs_assoc nm =
+ case lookupFixity fixs_assoc nm of
+ Fixity _ InfixN -> (False, False)
+ Fixity _ InfixR -> (False, True)
+ Fixity _ InfixL -> (True, False)
+
+lookupFixity :: Fixities -> Name -> Fixity
+lookupFixity fixs_assoc nm = assocDefault defaultFixity fixs_assoc nm