Use new showMultiLineString to fix Trac #4436
[ghc-hetmet.git] / compiler / utils / Outputable.lhs
index 73c6bd3..37f116c 100644 (file)
@@ -75,14 +75,24 @@ import Pretty               ( Doc, Mode(..) )
 import Panic
 
 import Data.Char
-import Data.Map (Map)
 import qualified Data.Map as M
+import qualified Data.IntMap as IM
 import Data.Word
 import System.IO       ( Handle, stderr, stdout, hFlush )
 import System.FilePath
+
+
+#if __GLASGOW_HASKELL__ >= 700
+import GHC.Show                ( showMultiLineString )
+#else
+showMultiLineString :: String -> [String]
+-- Crude version
+showMultiLineString s = [s]
+#endif
 \end{code}
 
 
+
 %************************************************************************
 %*                                                                     *
 \subsection{The @PprStyle@ data type}
@@ -567,8 +577,10 @@ instance Outputable FastString where
     ppr fs = ftext fs          -- Prints an unadorned string,
                                -- no double quotes or anything
 
-instance (Outputable key, Outputable elt) => Outputable (Map key elt) where
+instance (Outputable key, Outputable elt) => Outputable (M.Map key elt) where
     ppr m = ppr (M.toList m)
+instance (Outputable elt) => Outputable (IM.IntMap elt) where
+    ppr m = ppr (IM.toList m)
 \end{code}
 
 %************************************************************************
@@ -606,7 +618,7 @@ pprHsChar c | c > '\x10ffff' = char '\\' <> text (show (fromIntegral (ord c) ::
 
 -- | Special combinator for showing string literals.
 pprHsString :: FastString -> SDoc
-pprHsString fs = text (show (unpackFS fs))
+pprHsString fs = vcat (map text (showMultiLineString (unpackFS fs)))
 
 ---------------------
 -- Put a name in parens if it's an operator