-type Error = PprStyle -> Pretty
-type Warning = PprStyle -> Pretty
-type Message = PprStyle -> Pretty
-
-addErrLoc :: SrcLoc -> String -> Error -> Error
-addErrLoc locn title rest_of_err_msg sty
- = ppHang (ppBesides [ppr PprForUser locn,
- if null title then ppNil else ppStr (": " ++ title),
- ppChar ':'])
- 4 (rest_of_err_msg sty)
-
-addShortErrLocLine, addShortWarnLocLine :: SrcLoc -> Error -> Error
-
-addShortErrLocLine locn rest_of_err_msg sty
- = ppHang (ppBeside (ppr PprForUser locn) (ppChar ':'))
- 4 (rest_of_err_msg sty)
-
-addShortWarnLocLine locn rest_of_err_msg sty
- = ppHang (ppBeside (ppr PprForUser locn) (ppPStr SLIT(":warning:")))
- 4 (rest_of_err_msg sty)
-
-dontAddErrLoc :: String -> Error -> Error
-dontAddErrLoc title rest_of_err_msg sty
- = ppHang (ppBesides [ppStr title, ppChar ':'])
- 4 (rest_of_err_msg sty)
-
-pprBagOfErrors :: PprStyle -> Bag Error -> Pretty
-pprBagOfErrors sty bag_of_errors
- = let pretties = map ( \ e -> e sty ) (bagToList bag_of_errors) in
- ppAboves (map (\ p -> ppAbove ppSP p) pretties)
+type MsgWithLoc = (SrcLoc, SDoc)
+
+type ErrMsg = MsgWithLoc
+type WarnMsg = MsgWithLoc
+type Message = SDoc
+
+addShortErrLocLine :: SrcLoc -> Message -> ErrMsg
+addErrLocHdrLine :: SrcLoc -> Message -> Message -> ErrMsg
+addShortWarnLocLine :: SrcLoc -> Message -> WarnMsg
+
+addShortErrLocLine locn rest_of_err_msg
+ | isGoodSrcLoc locn = (locn, hang (ppr locn <> colon) 4
+ rest_of_err_msg)
+ | otherwise = (locn, rest_of_err_msg)
+
+addErrLocHdrLine locn hdr rest_of_err_msg
+ = ( locn
+ , hang (ppr locn <> colon<+> hdr)
+ 4 rest_of_err_msg
+ )
+
+addShortWarnLocLine locn rest_of_err_msg
+ | isGoodSrcLoc locn = (locn, hang (ppr locn <> colon) 4
+ (ptext SLIT("Warning:") <+> rest_of_err_msg))
+ | otherwise = (locn, rest_of_err_msg)
+
+dontAddErrLoc :: Message -> ErrMsg
+dontAddErrLoc msg = (noSrcLoc, msg)
+