ppr wibble; new functions: dumpIfSet, doIfSet
addShortErrLocLine, addShortWarnLocLine,
dontAddErrLoc,
pprBagOfErrors,
addShortErrLocLine, addShortWarnLocLine,
dontAddErrLoc,
pprBagOfErrors,
+ ghcExit,
+ doIfSet, dumpIfSet
) where
IMP_Ubiq(){-uitous-}
import CmdLineOpts ( opt_PprUserLength )
import Bag --( bagToList )
) where
IMP_Ubiq(){-uitous-}
import CmdLineOpts ( opt_PprUserLength )
import Bag --( bagToList )
-import Outputable ( PprStyle(..), Outputable(..) )
+import Outputable ( PprStyle(..), Outputable(..), printErrs )
import Pretty
import SrcLoc ( noSrcLoc, SrcLoc{-instance-} )
\end{code}
import Pretty
import SrcLoc ( noSrcLoc, SrcLoc{-instance-} )
\end{code}
pprBagOfErrors :: PprStyle -> Bag Error -> Doc
pprBagOfErrors sty bag_of_errors
pprBagOfErrors :: PprStyle -> Bag Error -> Doc
pprBagOfErrors sty bag_of_errors
- = let pretties = map ( \ e -> e sty ) (bagToList bag_of_errors) in
+ = let pretties = map ( \ e -> e sty ) (bagToList bag_of_errors)
+ in
vcat (map (\ p -> ($$) space p) pretties)
\end{code}
vcat (map (\ p -> ($$) space p) pretties)
\end{code}
then error "Compilation had errors\n"
else return ()
\end{code}
then error "Compilation had errors\n"
else return ()
\end{code}
+
+\begin{code}
+doIfSet :: Bool -> IO () -> IO ()
+doIfSet flag action | flag = action
+ | otherwise = return ()
+\end{code}
+
+\begin{code}
+dumpIfSet :: Bool -> String -> Doc -> IO ()
+dumpIfSet flag hdr doc
+ | not flag = return ()
+ | otherwise = printErrs dump
+ where
+ dump = (line <+> text hdr <+> line)
+ $$
+ doc
+ $$
+ text ""
+ line = text (take 20 (repeat '='))
+\end{code}