-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Robust prettyprinter for output of auto-generated Show
--   instances
--   
--   See README.md
@package show-prettyprint
@version 0.2.0.2


-- | <b>This module may change arbitrarily between versions.</b> It is
--   exposed only for documentary purposes.
module Text.Show.Prettyprint.Internal

-- | Prettyparser for a <a>show</a>-generated string
shownP :: Parser (Doc ann)

-- | Prettyparser for a constructor, which is roughly a word applied to
--   arguments.
--   
--   <pre>
--   &gt;&gt;&gt; testParse valueP "Just ('c', Left ())"
--   Just ('c',Left ())
--   </pre>
valueP :: Parser (Doc ann)

-- | An identifier is a liberal version of a "variable or constructor",
--   which roughly means that it's a printable word without parentheses.
--   
--   <pre>
--   &gt;&gt;&gt; testParse identifierP "_foo'bar"
--   _foo'bar
--   </pre>
identifierP :: Parser (Doc ann)

-- | Number in integer or scientific notation.
--   
--   <pre>
--   &gt;&gt;&gt; testParse numberP "123456"
--   123456
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; testParse numberP "-123.4e56"
--   -1.234e58
--   </pre>
numberP :: Parser (Doc ann)

-- | <pre>
--   &gt;&gt;&gt; testParse stringLitP "\"Hello world!\""
--   "Hello world!"
--   </pre>
stringLitP :: Parser (Doc ann)

-- | <pre>
--   &gt;&gt;&gt; testParse charLitP "'c'"
--   'c'
--   </pre>
charLitP :: Parser (Doc ann)

-- | Anything that could be considered an argument to something else.
--   
--   <pre>
--   &gt;&gt;&gt; testParse argP "()"
--   ()
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; testParse argP "['h', 'e', 'l', 'l', 'o']"
--   ['h','e','l','l','o']
--   </pre>
argP :: Parser (Doc ann)

-- | <pre>
--   &gt;&gt;&gt; testParse unitP "()"
--   ()
--   </pre>
unitP :: Parser (Doc ann)

-- | Prettyparser for tuples from size 1. Since 1-tuples are just
--   parenthesized expressions to first order approximation, this parser
--   handles those as well.
--   
--   <pre>
--   &gt;&gt;&gt; testParse tupleP "((), True, 'c')"
--   ((),True,'c')
--   </pre>
tupleP :: Parser (Doc ann)

-- | List prettyparser. Lists can be heterogeneous, which is realistic if
--   we consider ill-defined Show instances.
--   
--   <pre>
--   &gt;&gt;&gt; testParse listP "[\"Hello\", World]"
--   ["Hello",World]
--   </pre>
listP :: Parser (Doc ann)

-- | <pre>
--   &gt;&gt;&gt; testParse recordP "{ r1 = (), r2 = Just True }"
--   {r1 = (),r2 = Just True}
--   </pre>
recordP :: Parser (Doc ann)


-- | These functions are identical to the ones in the main module, but
--   instead of falling back to the un-prettyprinted input, they will
--   report an error on failure.
--   
--   <pre>
--   &gt;&gt;&gt; putStrLn (prettifyShowErr "Imbalanced (Parenthesis)) here")
--   ERROR (interactive):1:25: error: expected: char literal,
--       end of input, identifier, list,
--       number, record, string literal,
--       tuple, unit
--   Imbalanced (Parenthesis)) here&lt;EOF&gt;
--                           ^
--   </pre>
module Text.Show.Prettyprint.Diagnostic

-- | Attempt to prettify a string produced by <a>show</a>. Report error
--   information on failure.
prettifyShowErr :: String -> String

-- | <a>prettifyShowErr</a> with the <a>show</a> baked in.
prettyShowErr :: Show a => a -> String

-- | <a>prettifyShowErr</a> with the <a>show</a> and the <a>putStrLn</a>
--   baked in.
prettyPrintErr :: Show a => a -> IO ()


-- | Format a <a>show</a>-generated string to make it nicer to read.
--   
--   For example, consider this nested data structure:
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   let nestedExample = fromList
--           [ ("hello", Left  (Pair True ()))
--           , ("world", Right (Record { r1 = ('c', -1.2e34), r2 = 123 }))
--           , ("!"    , Left  (Pair False ())) ]
--   :}
--   </pre>
--   
--   Applying <a>show</a> to it results in the fairly dense representation
--   
--   <pre>
--   &gt;&gt;&gt; print nestedExample
--   fromList [("!",Left (Pair False ())),("hello",Left (Pair True ())),("world",Right (Record {r1 = ('c',-1.2e34), r2 = 123}))]
--   </pre>
--   
--   With the functions defined in this module, we can make this output a
--   bit more readable,
--   
--   <pre>
--   &gt;&gt;&gt; prettyPrint nestedExample
--   fromList [("!",Left (Pair False ()))
--            ,("hello",Left (Pair True ()))
--            ,("world",Right (Record {r1 = ('c',-1.2e34),r2 = 123}))]
--   </pre>
module Text.Show.Prettyprint

-- | Prettyprint a string produced by <a>show</a>. On parse error, silently
--   fall back to a non-prettyprinted version.
prettifyShow :: String -> String

-- | <a>prettifyShow</a> with the <a>show</a> baked in.
prettyShow :: Show a => a -> String

-- | <a>prettifyShow</a> with the <a>show</a> and the <a>putStrLn</a> baked
--   in.
prettyPrint :: Show a => a -> IO ()
