Safe Haskell | None |
---|---|
Language | Haskell2010 |
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}))]
- prettifyShow :: String -> String
- prettifyToDoc :: String -> Doc ann
- prettyShow :: Show a => a -> String
- prettyPrint :: Show a => a -> IO ()
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.
prettyPrint :: Show a => a -> IO () Source #
prettifyShow
with the show
and the putStrLn
baked in.