prettyclass-1.0.0.0: Pretty printing class similar to Show.

Safe Haskell | Safe
Language | Haskell98

Text.PrettyPrint.HughesPJClass

Description

Pretty printing class, simlar to `Show` but nicer looking. Note that the precedence level is a `Rational` so there is an unlimited number of levels. Based on Text.PrettyPrint.HughesPJ, which is re-exported.

Synopsis

- class Pretty a where
  - pPrintPrec :: PrettyLevel -> Rational -> a -> Doc
  - pPrint :: a -> Doc
  - pPrintList :: PrettyLevel -> [a] -> Doc
- newtype PrettyLevel = PrettyLevel Int
- prettyNormal :: PrettyLevel
- prettyShow :: Pretty a => a -> String
- prettyParen :: Bool -> Doc -> Doc
- module Text.PrettyPrint.HughesPJ

# Documentation

class Pretty a where Source

Pretty printing class. The precedence level is used in a similar way as in the `Show` class. Minimal complete definition is either `pPrintPrec` or `pPrint`.

Minimal complete definition

Nothing

Methods

pPrintPrec :: PrettyLevel -> Rational -> a -> Doc Source

pPrint :: a -> Doc Source

pPrintList :: PrettyLevel -> [a] -> Doc Source

Instances

Pretty Bool Source |
Pretty Char Source |
Pretty Double Source |
Pretty Float Source |
Pretty Int Source |
Pretty Integer Source |
Pretty Ordering Source |
Pretty () Source |
Pretty a => Pretty [a] Source |
Pretty a => Pretty (Maybe a) Source |
(Pretty a, Pretty b) => Pretty (Either a b) Source |
(Pretty a, Pretty b) => Pretty (a, b) Source |
(Pretty a, Pretty b, Pretty c) => Pretty (a, b, c) Source |
(Pretty a, Pretty b, Pretty c, Pretty d) => Pretty (a, b, c, d) Source |
(Pretty a, Pretty b, Pretty c, Pretty d, Pretty e) => Pretty (a, b, c, d, e) Source |
(Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f) => Pretty (a, b, c, d, e, f) Source |
(Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g) => Pretty (a, b, c, d, e, f, g) Source |
(Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h) => Pretty (a, b, c, d, e, f, g, h) Source |

newtype PrettyLevel Source

Level of detail in the pretty printed output. Level 0 is the least detail.

Constructors

PrettyLevel Int |

Instances

Eq PrettyLevel Source |
Ord PrettyLevel Source |
Show PrettyLevel Source |

prettyNormal :: PrettyLevel Source

prettyShow :: Pretty a => a -> String Source

Pretty print a value with the `prettyNormal` level.

prettyParen :: Bool -> Doc -> Doc Source

Parenthesize an value if the boolean is true.

module Text.PrettyPrint.HughesPJ