[commit: packages/pretty] large_docs, moretests: Add appropriate Show, Eq and Generic instances (912f63c)

git at git.haskell.org git at git.haskell.org
Fri Jan 23 22:49:38 UTC 2015


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

On branches: large_docs,moretests
Link       : http://git.haskell.org/packages/pretty.git/commitdiff/912f63cf490064d0f071c60fb71d6ce7e6205897

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

commit 912f63cf490064d0f071c60fb71d6ce7e6205897
Author: David Terei <code at davidterei.com>
Date:   Thu Dec 25 01:35:46 2014 -0800

    Add appropriate Show, Eq and Generic instances


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

912f63cf490064d0f071c60fb71d6ce7e6205897
 pretty.cabal                     |  8 +++++---
 src/Text/PrettyPrint/HughesPJ.hs | 15 +++++++++++++++
 tests/PrettyTestVersion.hs       |  4 ++++
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/pretty.cabal b/pretty.cabal
index 47c1a8f..e97ac11 100644
--- a/pretty.cabal
+++ b/pretty.cabal
@@ -32,8 +32,9 @@ Library
         Text.PrettyPrint.HughesPJ
         Text.PrettyPrint.HughesPJClass
     build-depends: base >= 3 && < 5,
-                   deepseq >= 1.1
-    extensions: CPP, BangPatterns
+                   deepseq >= 1.1,
+                   ghc-prim
+    extensions: CPP, BangPatterns, DeriveGeneric
     ghc-options: -Wall -fwarn-tabs
 
 Test-Suite test-pretty
@@ -42,12 +43,13 @@ Test-Suite test-pretty
                     src
     build-depends: base >= 3 && < 5,
                    deepseq >= 1.1,
+                   ghc-prim,
                    QuickCheck >= 2.5 && <3
     main-is: Test.hs
     other-modules:
         TestGenerators
         TestStructures
-    extensions: CPP, BangPatterns
+    extensions: CPP, BangPatterns, DeriveGeneric
     include-dirs: src/Text/PrettyPrint
 
 -- Executable Bench1
diff --git a/src/Text/PrettyPrint/HughesPJ.hs b/src/Text/PrettyPrint/HughesPJ.hs
index 9ed67b2..f0efbd1 100644
--- a/src/Text/PrettyPrint/HughesPJ.hs
+++ b/src/Text/PrettyPrint/HughesPJ.hs
@@ -2,6 +2,7 @@
 {-# LANGUAGE BangPatterns #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Safe #-}
+{-# LANGUAGE DeriveGeneric #-}
 #endif
 
 -----------------------------------------------------------------------------
@@ -81,6 +82,8 @@ import Data.Function   ( on )
 import Data.Monoid     ( Monoid(mempty, mappend) )
 import Data.String     ( IsString(fromString) )
 
+import GHC.Generics
+
 -- ---------------------------------------------------------------------------
 -- The Doc calculus
 
@@ -178,6 +181,9 @@ data Doc
   | NoDoc                                            -- The empty set of documents
   | Beside Doc Bool Doc                              -- True <=> space between
   | Above Doc Bool Doc                               -- True <=> never overlap
+#if __GLASGOW_HASKELL__ >= 701
+  deriving (Generic)
+#endif
 
 {-
 Here are the invariants:
@@ -225,6 +231,9 @@ data TextDetails = Chr  {-# UNPACK #-} !Char -- ^ A single Char fragment
                  | PStr String -- ^ Used to represent a Fast String fragment
                                --   but now deprecated and identical to the
                                --   Str constructor.
+#if __GLASGOW_HASKELL__ >= 701
+                 deriving (Show, Eq, Generic)
+#endif
 
 -- Combining @Doc@ values
 instance Monoid Doc where
@@ -833,6 +842,9 @@ data Style
           , lineLength     :: Int   -- ^ Length of line, in chars
           , ribbonsPerLine :: Float -- ^ Ratio of line length to ribbon length
           }
+#if __GLASGOW_HASKELL__ >= 701
+  deriving (Show, Eq, Generic)
+#endif
 
 -- | The default style (@mode=PageMode, lineLength=100, ribbonsPerLine=1.5@).
 style :: Style
@@ -843,6 +855,9 @@ data Mode = PageMode     -- ^ Normal
           | ZigZagMode   -- ^ With zig-zag cuts
           | LeftMode     -- ^ No indentation, infinitely long lines
           | OneLineMode  -- ^ All on one line
+#if __GLASGOW_HASKELL__ >= 701
+          deriving (Show, Eq, Generic)
+#endif
 
 -- | Render the @Doc@ to a String using the default @Style at .
 render :: Doc -> String
diff --git a/tests/PrettyTestVersion.hs b/tests/PrettyTestVersion.hs
index 4a7cf6b..557504e 100644
--- a/tests/PrettyTestVersion.hs
+++ b/tests/PrettyTestVersion.hs
@@ -1,4 +1,8 @@
 {-# LANGUAGE CPP #-}
+{-# LANGUAGE BangPatterns #-}
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE DeriveGeneric #-}
+#endif
 
 #define TESTING
 



More information about the ghc-commits mailing list