+Consider
+ a `op1` b `op2` c
+
+(compareFixity op1 op2) tells which way to arrange appication, or
+whether there's an error.
+
+\begin{code}
+compareFixity :: Fixity -> Fixity
+ -> (Bool, -- Error please
+ Bool) -- Associate to the right: a op1 (b op2 c)
+compareFixity (Fixity prec1 dir1) (Fixity prec2 dir2)
+ = case prec1 `compare` prec2 of
+ GT -> left
+ LT -> right
+ EQ -> case (dir1, dir2) of
+ (InfixR, InfixR) -> right
+ (InfixL, InfixL) -> left
+ _ -> error_please
+ where
+ right = (False, True)
+ left = (False, False)
+ error_please = (True, False)
+\end{code}
+
+%************************************************************************
+%* *
+\subsubsection{Literals}
+%* *
+%************************************************************************
+
+When literals occur we have to make sure that the types and classes they involve
+are made available.
+
+\begin{code}
+litOccurrence (HsChar _)
+ = addImplicitOccRn charTyCon_name
+
+litOccurrence (HsCharPrim _)
+ = addImplicitOccRn (getName charPrimTyCon)
+
+litOccurrence (HsString _)
+ = addImplicitOccRn listTyCon_name `thenRn_`
+ addImplicitOccRn charTyCon_name
+
+litOccurrence (HsStringPrim _)
+ = addImplicitOccRn (getName addrPrimTyCon)
+
+litOccurrence (HsInt _)
+ = lookupImplicitOccRn numClass_RDR -- Int and Integer are forced in by Num
+
+litOccurrence (HsFrac _)
+ = lookupImplicitOccRn fractionalClass_RDR `thenRn_`
+ lookupImplicitOccRn ratioDataCon_RDR
+ -- We have to make sure that the Ratio type is imported with
+ -- its constructor, because literals of type Ratio t are
+ -- built with that constructor.
+ -- The Rational type is needed too, but that will come in
+ -- when fractionalClass does.
+
+litOccurrence (HsIntPrim _)
+ = addImplicitOccRn (getName intPrimTyCon)
+
+litOccurrence (HsFloatPrim _)
+ = addImplicitOccRn (getName floatPrimTyCon)
+
+litOccurrence (HsDoublePrim _)
+ = addImplicitOccRn (getName doublePrimTyCon)
+
+litOccurrence (HsLitLit _)
+ = lookupImplicitOccRn ccallableClass_RDR
+\end{code}
+
+%************************************************************************
+%* *
+\subsubsection{Assertion utils}
+%* *
+%************************************************************************
+
+\begin{code}
+mkAssertExpr :: RnMS s RenamedHsExpr
+mkAssertExpr =
+ newImportedGlobalName mod occ HiFile `thenRn` \ name ->
+ addOccurrenceName name `thenRn_`
+ getSrcLocRn `thenRn` \ sloc ->
+ let
+ expr = HsApp (HsVar name)
+ (HsLit (HsString (_PK_ (showSDoc (ppr sloc)))))
+ in
+ returnRn expr
+
+ where
+ mod = rdrNameModule assertErr_RDR
+ occ = rdrNameOcc assertErr_RDR
+\end{code}
+
+%************************************************************************
+%* *
+\subsubsection{Errors}
+%* *
+%************************************************************************
+