Text.PrettyPrint.HughesPJClass

pretty-1.1.3.3: 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
- 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 # |
Methods pPrintPrec :: PrettyLevel -> Rational -> Bool -> Doc Source # pPrint :: Bool -> Doc Source # pPrintList :: PrettyLevel -> [Bool] -> Doc Source #
Pretty Char # |
Methods pPrintPrec :: PrettyLevel -> Rational -> Char -> Doc Source # pPrint :: Char -> Doc Source # pPrintList :: PrettyLevel -> [Char] -> Doc Source #
Pretty Double # |
Methods pPrintPrec :: PrettyLevel -> Rational -> Double -> Doc Source # pPrint :: Double -> Doc Source # pPrintList :: PrettyLevel -> [Double] -> Doc Source #
Pretty Float # |
Methods pPrintPrec :: PrettyLevel -> Rational -> Float -> Doc Source # pPrint :: Float -> Doc Source # pPrintList :: PrettyLevel -> [Float] -> Doc Source #
Pretty Int # |
Methods pPrintPrec :: PrettyLevel -> Rational -> Int -> Doc Source # pPrint :: Int -> Doc Source # pPrintList :: PrettyLevel -> [Int] -> Doc Source #
Pretty Integer # |
Methods pPrintPrec :: PrettyLevel -> Rational -> Integer -> Doc Source # pPrint :: Integer -> Doc Source # pPrintList :: PrettyLevel -> [Integer] -> Doc Source #
Pretty Ordering # |
Methods pPrintPrec :: PrettyLevel -> Rational -> Ordering -> Doc Source # pPrint :: Ordering -> Doc Source # pPrintList :: PrettyLevel -> [Ordering] -> Doc Source #
Pretty () # |
Methods pPrintPrec :: PrettyLevel -> Rational -> () -> Doc Source # pPrint :: () -> Doc Source # pPrintList :: PrettyLevel -> [()] -> Doc Source #
Pretty a => Pretty [a] # |
Methods pPrintPrec :: PrettyLevel -> Rational -> [a] -> Doc Source # pPrint :: [a] -> Doc Source # pPrintList :: PrettyLevel -> [[a]] -> Doc Source #
Pretty a => Pretty (Maybe a) # |
Methods pPrintPrec :: PrettyLevel -> Rational -> Maybe a -> Doc Source # pPrint :: Maybe a -> Doc Source # pPrintList :: PrettyLevel -> [Maybe a] -> Doc Source #
(Pretty a, Pretty b) => Pretty (Either a b) # |
Methods pPrintPrec :: PrettyLevel -> Rational -> Either a b -> Doc Source # pPrint :: Either a b -> Doc Source # pPrintList :: PrettyLevel -> [Either a b] -> Doc Source #
(Pretty a, Pretty b) => Pretty (a, b) # |
Methods pPrintPrec :: PrettyLevel -> Rational -> (a, b) -> Doc Source # pPrint :: (a, b) -> Doc Source # pPrintList :: PrettyLevel -> [(a, b)] -> Doc Source #
(Pretty a, Pretty b, Pretty c) => Pretty (a, b, c) # |
Methods pPrintPrec :: PrettyLevel -> Rational -> (a, b, c) -> Doc Source # pPrint :: (a, b, c) -> Doc Source # pPrintList :: PrettyLevel -> [(a, b, c)] -> Doc Source #
(Pretty a, Pretty b, Pretty c, Pretty d) => Pretty (a, b, c, d) # |
Methods pPrintPrec :: PrettyLevel -> Rational -> (a, b, c, d) -> Doc Source # pPrint :: (a, b, c, d) -> Doc Source # pPrintList :: PrettyLevel -> [(a, b, c, d)] -> Doc Source #
(Pretty a, Pretty b, Pretty c, Pretty d, Pretty e) => Pretty (a, b, c, d, e) # |
Methods pPrintPrec :: PrettyLevel -> Rational -> (a, b, c, d, e) -> Doc Source # pPrint :: (a, b, c, d, e) -> Doc Source # pPrintList :: PrettyLevel -> [(a, b, c, d, e)] -> Doc Source #
(Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f) => Pretty (a, b, c, d, e, f) # |
Methods pPrintPrec :: PrettyLevel -> Rational -> (a, b, c, d, e, f) -> Doc Source # pPrint :: (a, b, c, d, e, f) -> Doc Source # pPrintList :: PrettyLevel -> [(a, b, c, d, e, f)] -> Doc Source #
(Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g) => Pretty (a, b, c, d, e, f, g) # |
Methods pPrintPrec :: PrettyLevel -> Rational -> (a, b, c, d, e, f, g) -> Doc Source # pPrint :: (a, b, c, d, e, f, g) -> Doc Source # pPrintList :: PrettyLevel -> [(a, b, c, d, e, f, g)] -> Doc 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) # |
Methods pPrintPrec :: PrettyLevel -> Rational -> (a, b, c, d, e, f, g, h) -> Doc Source # pPrint :: (a, b, c, d, e, f, g, h) -> Doc Source # pPrintList :: PrettyLevel -> [(a, b, c, d, e, f, g, h)] -> Doc Source #

newtype PrettyLevel Source #

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

Constructors

PrettyLevel Int |

Instances

Eq PrettyLevel # |
Methods (==) :: PrettyLevel -> PrettyLevel -> Bool Source # (/=) :: PrettyLevel -> PrettyLevel -> Bool Source #
Ord PrettyLevel # |
Methods compare :: PrettyLevel -> PrettyLevel -> Ordering Source # (<) :: PrettyLevel -> PrettyLevel -> Bool Source # (<=) :: PrettyLevel -> PrettyLevel -> Bool Source # (>) :: PrettyLevel -> PrettyLevel -> Bool Source # (>=) :: PrettyLevel -> PrettyLevel -> Bool Source # max :: PrettyLevel -> PrettyLevel -> PrettyLevel Source # min :: PrettyLevel -> PrettyLevel -> PrettyLevel Source #
Show PrettyLevel # |
Methods showsPrec :: Int -> PrettyLevel -> ShowS Source # show :: PrettyLevel -> String Source # showList :: [PrettyLevel] -> ShowS Source #

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