pretty-1.1.2.0: Pretty-printing library

Copyright | (c) Lennart Augustsson 2014
License | BSD-style (see the file LICENSE)
Maintainer | David Terei <code@davidterei.com>
Stability | stable
Portability | portable
Safe Haskell | Safe
Language | Haskell98

Text.PrettyPrint.HughesPJClass

Contents

- Pretty typeclass

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. This module re-exports `HughesPJ`.

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

# Pretty typeclass

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

pPrintPrec | pPrint

Methods

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

pPrint :: a -> Doc Source

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

Instances

Pretty Bool |
Pretty Char |
Pretty Double |
Pretty Float |
Pretty Int |
Pretty Integer |
Pretty Ordering |
Pretty () |
Pretty a => Pretty [a] |
Pretty a => Pretty (Maybe a) |
(Pretty a, Pretty b) => Pretty (Either a b) |
(Pretty a, Pretty b) => Pretty (a, b) |
(Pretty a, Pretty b, Pretty c) => Pretty (a, b, c) |
(Pretty a, Pretty b, Pretty c, Pretty d) => Pretty (a, b, c, d) |
(Pretty a, Pretty b, Pretty c, Pretty d, Pretty e) => Pretty (a, b, c, d, e) |
(Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f) => Pretty (a, b, c, d, e, f) |
(Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g) => Pretty (a, b, c, d, e, f, g) |
(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) |

newtype PrettyLevel Source

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

Constructors

PrettyLevel Int |

Instances

Eq PrettyLevel |
Ord PrettyLevel |
Show PrettyLevel |

prettyNormal :: PrettyLevel Source

The "normal" (Level 0) of detail.

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

Pretty print a value with the `prettyNormal` level.

prettyParen :: Bool -> Doc -> Doc Source

Deprecated: Please use `maybeParens` instead

Parenthesize an value if the boolean is true.

module Text.PrettyPrint.HughesPJ