show-prettyprint-0.2.2: Robust prettyprinter for output of auto-generated Show instances

Safe HaskellNone
LanguageHaskell2010

Text.Show.Prettyprint

Description

Format a show-generated string to make it nicer to read.

For example, consider this nested data structure:

>>> :{
let nestedExample = fromList
        [ ("hello", Left  (Pair True ()))
        , ("world", Right (Record { r1 = ('c', -1.2e34), r2 = 123 }))
        , ("!"    , Left  (Pair False ())) ]
:}

Applying show to it results in the fairly dense representation

>>> print nestedExample
fromList [("!",Left (Pair False ())),("hello",Left (Pair True ())),("world",Right (Record {r1 = ('c',-1.2e34), r2 = 123}))]

With the functions defined in this module, we can make this output a bit more readable,

>>> prettyPrint nestedExample
fromList [("!",Left (Pair False ()))
         ,("hello",Left (Pair True ()))
         ,("world",Right (Record {r1 = ('c',-1.2e34),r2 = 123}))]

Synopsis

Documentation

prettifyShow :: String -> String Source #

Prettyprint a string produced by show. On parse error, silently fall back to a non-prettyprinted version.

prettifyToDoc :: String -> Doc ann Source #

Like prettifyShow, but maps to a Doc for easier interoperability with the prettyprinter package.

prettyShow :: Show a => a -> String Source #

prettifyShow with the show baked in.

prettyShowDoc :: Show a => a -> Doc ann Source #

prettifyToDoc with the show baked in.

prettyPrint :: Show a => a -> IO () Source #

prettifyShow with the show and the putStrLn baked in.