import SrcLoc ( SrcLoc, noSrcLoc )
import Util ( sortLt )
import Outputable
+import CmdLineOpts ( DynFlags )
+
+import System ( ExitCode(..), exitWith )
import IO ( hPutStr, stderr )
\end{code}
\begin{code}
ghcExit :: Int -> IO ()
-
ghcExit val
- = if val /= 0
- then hPutStr stderr "\nCompilation had errors\n\n"
- else return ()
+ | val == 0 = exitWith ExitSuccess
+ | otherwise = do hPutStr stderr "\nCompilation had errors\n\n"
+ exitWith (ExitFailure val)
\end{code}
\begin{code}
\end{code}
\begin{code}
-dumpIfSet :: Bool -> String -> SDoc -> IO ()
-dumpIfSet flag hdr doc
- | not flag = return ()
- | otherwise = printDump dump
+dumpIfSet :: DynFlags -> (DynFlags -> Bool) -> String -> SDoc -> IO ()
+dumpIfSet dflags flag hdr doc
+ | not (flag dflags) = return ()
+ | otherwise = printDump dump
where
dump = vcat [text "",
line <+> text hdr <+> line,