Pretty printing for well-behaved Show instances.

Version on this page:0.1.2
LTS Haskell 8.23:
Stackage Nightly 2017-07-25:
Latest on Hackage:
BSD3 licensed by Edward Z. Yang
Maintained by

Module documentation for 0.1.2

Automatically derived Show instances are an easy way to inspect data in your program. However, for large data-structures, the resulting output lacks whitespace, making it unreadable. Groom offers an replacement to show called groom which attempts to pretty-print the output of show. For example:

let x = parseExp "foobar 1 [1,2]"
in do
  putStrLn (show x)
  putStrLn (groom x)

results in:

ParseOk (App (App (Var (UnQual (Ident "foobar"))) (Lit (Int 1))) (List [Lit (Int 1),Lit (Int 2)]))
  (App (App (Var (UnQual (Ident "foobar"))) (Lit (Int 1)))
     (List [Lit (Int 1), Lit (Int 2)]))

Groom works only on Show instances that output valid Haskell code; if Groom can't understand its input, it will not make any changes.

comments powered byDisqus