import Maybes ( maybeToBool )
import Constants
import List ( partition, intersperse )
-import Outputable ( pprPanic, ppr )
+import Outputable ( pprPanic, ppr, pprTrace )
#if __GLASGOW_HASKELL__ >= 404
import GlaExts ( fromInt )
c.f. Figure 18 in Haskell 1.1 report.
-}
paren_prec_limit
- | not is_infix = fromInt maxPrecedence
- | otherwise = getFixity get_fixity dc_nm
+ | not is_infix = defaultPrecedence
+ | otherwise = getPrecedence get_fixity dc_nm
read_paren_arg -- parens depend on precedence...
| nullary_con = false_Expr -- it's optional.
c.f. Figure 16 and 17 in Haskell 1.1 report
-}
paren_prec_limit
- | not is_infix = fromInt maxPrecedence + 1
- | otherwise = getFixity get_fixity dc_nm + 1
+ | not is_infix = defaultPrecedence + 1
+ | otherwise = getPrecedence get_fixity dc_nm + 1
\end{code}
cf. Figures 16-18 in Haskell 1.1 report.
-}
(con_left_assoc, con_right_assoc) = isLRAssoc get_fixity nm
- paren_con_prec = getFixity get_fixity nm
- maxPrec = fromInt maxPrecedence
+ paren_con_prec = getPrecedence get_fixity nm
lp
- | not is_infix = maxPrec + 1
+ | not is_infix = defaultPrecedence + 1
| con_left_assoc = paren_con_prec
| otherwise = paren_con_prec + 1
rp
- | not is_infix = maxPrec + 1
+ | not is_infix = defaultPrecedence + 1
| con_right_assoc = paren_con_prec
| otherwise = paren_con_prec + 1
-getFixity :: (Name -> Maybe Fixity) -> Name -> Integer
-getFixity get_fixity nm
+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 -> pprPanic "TcGenDeriv.getFixity" (ppr nm)
+ other -> pprTrace "TcGenDeriv.getPrecedence" (ppr nm) defaultPrecedence
isLRAssoc :: (Name -> Maybe Fixity) -> Name -> (Bool, Bool)
isLRAssoc get_fixity nm =