[project @ 1996-04-25 16:31:20 by partain]
[ghc-hetmet.git] / ghc / compiler / main / ErrUtils.lhs
index d455ff0..e50ded5 100644 (file)
@@ -7,14 +7,12 @@
 #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-}
@@ -27,6 +25,8 @@ import SrcLoc         ( mkUnknownSrcLoc, SrcLoc{-instance-} )
 
 \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
@@ -51,33 +51,11 @@ pprBagOfErrors sty bag_of_errors
     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}