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

Safe HaskellNone
LanguageHaskell2010

Text.Show.Prettyprint.Internal

Description

This module may change arbitrarily between versions. It is exposed only for documentary purposes.

Synopsis

Documentation

shownP :: Parser (Doc ann) Source #

Prettyparser for a show-generated string

valueP :: Parser (Doc ann) Source #

Prettyparser for a constructor, which is roughly a word applied to arguments.

>>> testParse valueP "Just ('c', Left ())"
Just ('c',Left ())

identifierP :: Parser (Doc ann) Source #

An identifier is a liberal version of a "variable or constructor", which roughly means that it's a printable word without parentheses.

>>> testParse identifierP "_foo'bar"
_foo'bar

numberP :: Parser (Doc ann) Source #

Number in integer or scientific notation.

>>> testParse numberP "123456"
123456
>>> testParse numberP "-123.4e56"
-1.234e58

stringLitP :: Parser (Doc ann) Source #

>>> testParse stringLitP "\"Hello world!\""
"Hello world!"

charLitP :: Parser (Doc ann) Source #

>>> testParse charLitP "'c'"
'c'

argP :: Parser (Doc ann) Source #

Anything that could be considered an argument to something else.

>>> testParse argP "()"
()
>>> testParse argP "['h', 'e', 'l', 'l', 'o']"
['h','e','l','l','o']

unitP :: Parser (Doc ann) Source #

>>> testParse unitP "()"
()

tupleP :: Parser (Doc ann) Source #

Prettyparser for tuples from size 1. Since 1-tuples are just parenthesized expressions to first order approximation, this parser handles those as well.

>>> testParse tupleP "((), True, 'c')"
((),True,'c')

listP :: Parser (Doc ann) Source #

List prettyparser. Lists can be heterogeneous, which is realistic if we consider ill-defined Show instances.

>>> testParse listP "[\"Hello\", World]"
["Hello",World]

recordP :: Parser (Doc ann) Source #

>>> testParse recordP "{ r1 = (), r2 = Just True }"
{r1 = (),r2 = Just True}