diff options
Diffstat (limited to 'compiler/GHC/Utils')
-rw-r--r-- | compiler/GHC/Utils/Binary.hs | 6 | ||||
-rw-r--r-- | compiler/GHC/Utils/Outputable.hs | 14 |
2 files changed, 19 insertions, 1 deletions
diff --git a/compiler/GHC/Utils/Binary.hs b/compiler/GHC/Utils/Binary.hs index 15071c1b37..5e11489572 100644 --- a/compiler/GHC/Utils/Binary.hs +++ b/compiler/GHC/Utils/Binary.hs @@ -77,6 +77,8 @@ module GHC.Utils.Binary import GHC.Prelude +import Language.Haskell.Syntax.Module.Name (ModuleName(..)) + import {-# SOURCE #-} GHC.Types.Name (Name) import GHC.Data.FastString import GHC.Utils.Panic.Plain @@ -1103,6 +1105,10 @@ instance Binary Fingerprint where put_ h (Fingerprint w1 w2) = do put_ h w1; put_ h w2 get h = do w1 <- get h; w2 <- get h; return (Fingerprint w1 w2) +instance Binary ModuleName where + put_ bh (ModuleName fs) = put_ bh fs + get bh = do fs <- get bh; return (ModuleName fs) + -- instance Binary FunctionOrData where -- put_ bh IsFunction = putByte bh 0 -- put_ bh IsData = putByte bh 1 diff --git a/compiler/GHC/Utils/Outputable.hs b/compiler/GHC/Utils/Outputable.hs index b70dfc793d..5c47ad6f27 100644 --- a/compiler/GHC/Utils/Outputable.hs +++ b/compiler/GHC/Utils/Outputable.hs @@ -78,6 +78,8 @@ module GHC.Utils.Outputable ( pprFastFilePath, pprFilePathString, + pprModuleName, + -- * Controlling the style in which output is printed BindingSite(..), @@ -104,7 +106,7 @@ module GHC.Utils.Outputable ( ) where -import {-# SOURCE #-} Language.Haskell.Syntax.ImpExp ( ModuleName ) +import Language.Haskell.Syntax.Module.Name ( ModuleName(..) ) import GHC.Prelude @@ -1039,6 +1041,16 @@ instance Outputable Serialized where instance Outputable Extension where ppr = text . show +instance Outputable ModuleName where + ppr = pprModuleName + +pprModuleName :: ModuleName -> SDoc +pprModuleName (ModuleName nm) = + getPprStyle $ \ sty -> + if codeStyle sty + then ztext (zEncodeFS nm) + else ftext nm + ----------------------------------------------------------------------- -- The @OutputableP@ class ----------------------------------------------------------------------- |