yav / pretty-show

Tools for working with derived Show instances in Haskell.
MIT License
57 stars 15 forks source link

add newtype Pretty #47

Closed yaitskov closed 1 year ago

yaitskov commented 1 year ago

Hi,

newtype Pretty a = Pretty a deriving (Eq)

instance Show a => Show (Pretty a) where
  show (Pretty a) = ppShow $ show a

It would be useful for writing tests, because Hunit assertEqual prints ugly message for complex values.

yav commented 1 year ago

Thanks for the suggestion! I just pushed a new version that has a newtype wrapper called PPShow give it a go, and let me know if it works as expected. I used that name because Pretty is already used in another module in pretty-show and tends to be a popular class for pretty printing libraries so it is more likely to clash with stuff.

Btw, I assume you meant:

instance Show a => Show (Pretty a) where
  show (Pretty a) = ppShow a
yaitskov commented 1 year ago

Thanks. Oh, you were right.