[commit: packages/pretty] master: Define Semigroup instances for base>=4.9 (d0ab406)

git at git.haskell.org git at git.haskell.org
Tue Apr 19 20:58:26 UTC 2016


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

On branch  : master
Link       : http://git.haskell.org/packages/pretty.git/commitdiff/d0ab406b82bb8d04bcdaac3672c2539d459f13a9

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

commit d0ab406b82bb8d04bcdaac3672c2539d459f13a9
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Fri Jan 1 10:39:59 2016 +0100

    Define Semigroup instances for base>=4.9
    
    This makes `pretty` almost `-Wcompat`-clean.
    
    The only remaining warning is about the local `<>` definitions
    clashing with a future Prelude exporting `(<>)`.


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

d0ab406b82bb8d04bcdaac3672c2539d459f13a9
 src/Text/PrettyPrint/Annotated/HughesPJ.hs | 13 ++++++++++++-
 src/Text/PrettyPrint/HughesPJ.hs           | 13 ++++++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/Text/PrettyPrint/Annotated/HughesPJ.hs b/src/Text/PrettyPrint/Annotated/HughesPJ.hs
index 02fe34c..674122c 100644
--- a/src/Text/PrettyPrint/Annotated/HughesPJ.hs
+++ b/src/Text/PrettyPrint/Annotated/HughesPJ.hs
@@ -84,7 +84,9 @@ module Text.PrettyPrint.Annotated.HughesPJ (
 
 import Control.DeepSeq ( NFData(rnf) )
 import Data.Function   ( on )
-#if __GLASGOW_HASKELL__ < 709
+#if __GLASGOW_HASKELL__ >= 800
+import qualified Data.Semigroup as Semi ( Semigroup((<>)) )
+#elif __GLASGOW_HASKELL__ < 709
 import Data.Monoid     ( Monoid(mempty, mappend)  )
 #endif
 import Data.String     ( IsString(fromString) )
@@ -258,9 +260,18 @@ data TextDetails = Chr  {-# UNPACK #-} !Char -- ^ A single Char fragment
 #endif
 
 -- Combining @Doc@ values
+#if __GLASGOW_HASKELL__ >= 800
+instance Semi.Semigroup (Doc a) where
+    (<>) = (Text.PrettyPrint.Annotated.HughesPJ.<>)
+
+instance Monoid (Doc a) where
+    mempty  = empty
+    mappend = (Semi.<>)
+#else
 instance Monoid (Doc a) where
     mempty  = empty
     mappend = (<>)
+#endif
 
 instance IsString (Doc a) where
     fromString = text
diff --git a/src/Text/PrettyPrint/HughesPJ.hs b/src/Text/PrettyPrint/HughesPJ.hs
index 090b222..5aa5018 100644
--- a/src/Text/PrettyPrint/HughesPJ.hs
+++ b/src/Text/PrettyPrint/HughesPJ.hs
@@ -87,7 +87,9 @@ import qualified Text.PrettyPrint.Annotated.HughesPJ as Ann
 
 import Control.DeepSeq ( NFData(rnf) )
 import Data.Function   ( on )
-#if __GLASGOW_HASKELL__ < 709
+#if __GLASGOW_HASKELL__ >= 800
+import qualified Data.Semigroup as Semi ( Semigroup((<>)) )
+#elif __GLASGOW_HASKELL__ < 709
 import Data.Monoid     ( Monoid(mempty, mappend)  )
 #endif
 import Data.String     ( IsString(fromString) )
@@ -127,9 +129,18 @@ liftBinary f (Doc a) (Doc b) = Doc (f a b)
 type RDoc = Doc
 
 -- Combining @Doc@ values
+#if __GLASGOW_HASKELL__ >= 800
+instance Semi.Semigroup Doc where
+    (<>) = (Text.PrettyPrint.HughesPJ.<>)
+
+instance Monoid Doc where
+    mempty  = empty
+    mappend = (Semi.<>)
+#else
 instance Monoid Doc where
     mempty  = empty
     mappend = (<>)
+#endif
 
 instance IsString Doc where
     fromString = text



More information about the ghc-commits mailing list