Skip to content

Commit 60741f8

Browse files
committed
Add a newypte wrapper that will call ppShow
1 parent 9085120 commit 60741f8

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

Text/Show/Pretty.hs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ module Text.Show.Pretty
3636
-- * Get location of data files
3737
, getDataDir
3838

39+
-- * PPShow newtype wrapper
40+
, PPShow(..)
41+
3942
, -- * Preprocessing of values
4043
PreProc(..), ppHide, ppHideNested, hideCon
4144

@@ -63,6 +66,17 @@ import Prelude
6366
ppValue :: Value -> Doc
6467
ppValue = valToDoc
6568

69+
{- | This is just a wrapper, so that calling `show` on a value will
70+
use `ppShow` on it instead. Convenient for writing tests, so that
71+
you get a prettier message if the test fails -}
72+
newtype PPShow a = PPShow a
73+
deriving (Eq,Ord)
74+
75+
instance Show a => Show (PPShow a) where
76+
show (PPShow a) = ppShow a
77+
78+
79+
6680
reify :: Show a => a -> Maybe Value
6781
reify = parseValue . show
6882

pretty-show.cabal

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: pretty-show
2-
version: 1.10
2+
version: 1.11
33
category: Text
44

55
synopsis: Tools for working with derived `Show` instances and generic
@@ -52,6 +52,8 @@ library
5252
pretty >= 1 && < 2,
5353
text,
5454
filepath,
55+
unordered-containers,
56+
hashable,
5557
ghc-prim
5658
ghc-options: -Wall -O2
5759
if impl(ghc < 7.4)

0 commit comments

Comments
 (0)