#include "HsVersions.h"
module ErrUtils (
-
- Error(..),
- addErrLoc, addShortErrLocLine,
- dontAddErrLoc, pprBagOfErrors,
-
- TcError(..), TcWarning(..), Message(..),
- mkTcErr, arityErr
-
+ Error(..), Warning(..), Message(..),
+ addErrLoc,
+ addShortErrLocLine,
+ dontAddErrLoc,
+ pprBagOfErrors,
+ ghcExit
) where
import Ubiq{-uitous-}
\begin{code}
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
ppAboves (map (\ p -> ppAbove ppSP p) pretties)
\end{code}
-TypeChecking Errors
-~~~~~~~~~~~~~~~~~~~
-
\begin{code}
-type Message = PprStyle -> Pretty
-type TcError = Message
-type TcWarning = Message
-
-
-mkTcErr :: SrcLoc -- Where
- -> [Message] -- Context
- -> Message -- What went wrong
- -> TcError -- The complete error report
-
-mkTcErr locn ctxt msg sty
- = ppHang (ppBesides [ppr PprForUser locn, ppStr ": ", msg sty])
- 4 (ppAboves [msg sty | msg <- ctxt])
-
+ghcExit :: Int -> IO ()
-arityErr kind name n m sty =
- ppBesides [ ppStr "`", ppr sty name, ppStr "' should have ",
- n_arguments, ppStr ", but has been given ", ppInt m, ppChar '.']
- where
- errmsg = kind ++ " has too " ++ quantity ++ " arguments"
- quantity | m < n = "few"
- | otherwise = "many"
- n_arguments | n == 0 = ppStr "no arguments"
- | n == 1 = ppStr "1 argument"
- | True = ppCat [ppInt n, ppStr "arguments"]
+ghcExit val
+ = if val /= 0
+ then error "Compilation had errors\n"
+ else return ()
\end{code}