+\begin{code}
+getLRPrecs :: Bool -> (Name -> Maybe Fixity) -> Name -> [Integer]
+getLRPrecs is_infix get_fixity 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 get_fixity nm
+ paren_con_prec = getPrecedence get_fixity nm
+
+ lp
+ | not is_infix = defaultPrecedence + 1
+ | con_left_assoc = paren_con_prec
+ | otherwise = paren_con_prec + 1
+
+ rp
+ | not is_infix = defaultPrecedence + 1
+ | con_right_assoc = paren_con_prec
+ | otherwise = paren_con_prec + 1
+
+defaultPrecedence :: Integer
+defaultPrecedence = fromInt maxPrecedence
+
+getPrecedence :: (Name -> Maybe Fixity) -> Name -> Integer
+getPrecedence get_fixity nm
+ = case get_fixity nm of
+ Just (Fixity x _) -> fromInt x
+ other -> defaultPrecedence
+
+isLRAssoc :: (Name -> Maybe Fixity) -> Name -> (Bool, Bool)
+isLRAssoc get_fixity nm =
+ case get_fixity nm `orElse` defaultFixity of
+ Fixity _ InfixN -> (False, False)
+ Fixity _ InfixR -> (False, True)
+ Fixity _ InfixL -> (True, False)
+
+isInfixOccName :: String -> Bool
+isInfixOccName str =
+ case str of
+ (':':_) -> True
+ _ -> False
+\end{code}
+
+