Fix CodingStyle#Warnings URLs
[ghc-hetmet.git] / compiler / utils / Outputable.lhs
index 4f8d320..2462ea2 100644 (file)
@@ -7,6 +7,12 @@ Outputable: defines classes for pretty-printing and forcing, both
 forms of ``output.''
 
 \begin{code}
+{-# OPTIONS -w #-}
+-- The above warning supression flag is a temporary kludge.
+-- While working on this module you are encouraged to remove it and fix
+-- any warnings in the module. See
+--     http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
+-- for details
 
 module Outputable (
        Outputable(..), OutputableBndr(..),     -- Class
@@ -36,7 +42,7 @@ module Outputable (
        hang, punctuate,
        speakNth, speakNTimes, speakN, speakNOf, plural,
 
-       printSDoc, printErrs, printDump,
+       printSDoc, printErrs, hPrintDump, printDump,
        printForC, printForAsm, printForUser,
        pprCode, mkCodeStyle,
        showSDoc, showSDocForUser, showSDocDebug, showSDocDump,
@@ -258,9 +264,12 @@ printErrs doc = do Pretty.printDoc PageMode stderr doc
                   hFlush stderr
 
 printDump :: SDoc -> IO ()
-printDump doc = do
-   Pretty.printDoc PageMode stdout (better_doc defaultDumpStyle)
-   hFlush stdout
+printDump doc = hPrintDump stdout doc
+
+hPrintDump :: Handle -> SDoc -> IO ()
+hPrintDump h doc = do
+   Pretty.printDoc PageMode h (better_doc defaultDumpStyle)
+   hFlush h
  where
    better_doc = doc $$ text ""
 
@@ -409,6 +418,10 @@ instance Outputable a => Outputable (Maybe a) where
   ppr Nothing = ptext SLIT("Nothing")
   ppr (Just x) = ptext SLIT("Just") <+> ppr x
 
+instance (Outputable a, Outputable b) => Outputable (Either a b) where
+  ppr (Left x)  = ptext SLIT("Left")  <+> ppr x
+  ppr (Right y) = ptext SLIT("Right") <+> ppr y
+
 -- ToDo: may not be used
 instance (Outputable a, Outputable b, Outputable c) => Outputable (a, b, c) where
     ppr (x,y,z) =