[commit: ghc] master: Add some Outputable instances (2ad46a8)

git at git.haskell.org git at git.haskell.org
Mon Feb 1 14:51:16 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/2ad46a860f0b648aaeff224109b6045da30304d7/ghc

>---------------------------------------------------------------

commit 2ad46a860f0b648aaeff224109b6045da30304d7
Author: Oleg Grenrus <oleg.grenrus at iki.fi>
Date:   Mon Feb 1 14:32:54 2016 +0100

    Add some Outputable instances
    
    Reviewers: austin, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1865


>---------------------------------------------------------------

2ad46a860f0b648aaeff224109b6045da30304d7
 compiler/main/DynFlags.hs    | 10 +++++++++-
 compiler/utils/Outputable.hs |  4 ++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 4b4eb77..13f3bd7 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -604,7 +604,10 @@ data WarningFlag =
    deriving (Eq, Show, Enum)
 
 data Language = Haskell98 | Haskell2010
-   deriving Enum
+   deriving (Eq, Enum, Show)
+
+instance Outputable Language where
+    ppr = text . show
 
 -- | The various Safe Haskell modes
 data SafeHaskellMode
@@ -1675,6 +1678,11 @@ Note [Verbosity levels]
 
 data OnOff a = On a
              | Off a
+  deriving (Eq, Show)
+
+instance Outputable a => Outputable (OnOff a) where
+  ppr (On x)  = text "On" <+> ppr x
+  ppr (Off x) = text "Off" <+> ppr x
 
 -- OnOffs accumulate in reverse order, so we use foldr in order to
 -- process them in the right order
diff --git a/compiler/utils/Outputable.hs b/compiler/utils/Outputable.hs
index 1abb1c5..bf0cc90 100644
--- a/compiler/utils/Outputable.hs
+++ b/compiler/utils/Outputable.hs
@@ -95,6 +95,7 @@ import Platform
 import Pretty           ( Doc, Mode(..) )
 import Panic
 import GHC.Serialized
+import GHC.LanguageExtensions (Extension)
 
 import Data.ByteString (ByteString)
 import qualified Data.ByteString as BS
@@ -815,6 +816,9 @@ instance Outputable a => Outputable (SCC a) where
 instance Outputable Serialized where
     ppr (Serialized the_type bytes) = int (length bytes) <+> text "of type" <+> text (show the_type)
 
+instance Outputable Extension where
+    ppr = text . show
+
 {-
 ************************************************************************
 *                                                                      *



More information about the ghc-commits mailing list