summaryrefslogtreecommitdiff
path: root/ghc/compiler/utils/Outputable.lhs
diff options
context:
space:
mode:
authorsof <unknown>1997-09-04 19:52:58 +0000
committersof <unknown>1997-09-04 19:52:58 +0000
commite376c9e1b8da2741389b9ad2322475e37284beb9 (patch)
tree9d95a2aa5e92305faf31dd348bfb9ae34907ea2a /ghc/compiler/utils/Outputable.lhs
parent83401d9289e609957fe0df23338dff706f69c54f (diff)
downloadhaskell-e376c9e1b8da2741389b9ad2322475e37284beb9.tar.gz
[project @ 1997-09-04 19:52:58 by sof]
new values: pprDumpStyle, pprErrorsStyle;new function printErrs
Diffstat (limited to 'ghc/compiler/utils/Outputable.lhs')
-rw-r--r--ghc/compiler/utils/Outputable.lhs21
1 files changed, 19 insertions, 2 deletions
diff --git a/ghc/compiler/utils/Outputable.lhs b/ghc/compiler/utils/Outputable.lhs
index f7fb7fc316..d72dc8528b 100644
--- a/ghc/compiler/utils/Outputable.lhs
+++ b/ghc/compiler/utils/Outputable.lhs
@@ -20,7 +20,9 @@ module Outputable (
ifPprInterface,
pprQuote,
- printDoc, interppSP, interpp'SP,
+ printDoc, printErrs, pprCols, pprDumpStyle, pprErrorsStyle,
+
+ interppSP, interpp'SP,
speakNth
@@ -38,6 +40,7 @@ import Ubiq ( Uniquable(..), Unique, Name ) -- FastString mentions it; todo: rm
#endif
+import CmdLineOpts ( opt_PprStyle_All, opt_PprStyle_Debug, opt_PprStyle_User )
import FastString
import Pretty
import Util ( cmpPString )
@@ -156,15 +159,29 @@ instance (Outputable a, Outputable b, Outputable c) => Outputable (a, b, c) wher
%************************************************************************
\begin{code}
+pprCols = (100 :: Int) -- could make configurable
+
+-- pprErrorsStyle is the style to print ordinary error messages with
+-- pprDumpStyle is the style to print -ddump-xx information in
+(pprDumpStyle, pprErrorsStyle)
+ | opt_PprStyle_All = (PprShowAll, PprShowAll)
+ | opt_PprStyle_Debug = (PprDebug, PprDebug)
+ | otherwise = (PprDebug, PprQuote)
+
printDoc :: Mode -> Handle -> Doc -> IO ()
printDoc mode hdl doc
- = fullRender mode 100 1.5 put done doc
+ = fullRender mode pprCols 1.5 put done doc
where
put (Chr c) next = hPutChar hdl c >> next
put (Str s) next = hPutStr hdl s >> next
put (PStr s) next = hPutFS hdl s >> next
done = hPutChar hdl '\n'
+
+-- I'm not sure whether the direct-IO approach of printDoc
+-- above is better or worse than the put-big-string approach here
+printErrs :: Doc -> IO ()
+printErrs doc = hPutStr stderr (show (doc $$ text ""))
\end{code}