mainland-pretty-0.6.1: Pretty printing designed for printing source code.

Copyright (c) 2006-2011 Harvard University(c) 2011-2012 Geoffrey Mainland(c) 2015-2017 Drexel University BSD-style mainland@drexel.edu provisional portable None Haskell98

Text.PrettyPrint.Mainland.Class

Description

This module is based on A Prettier Printer by Phil Wadler in The Fun of Programming, Jeremy Gibbons and Oege de Moor (eds) http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf

At the time it was originally written I didn't know about Daan Leijen's pretty printing module based on the same paper. I have since incorporated many of his improvements. This module is geared towards pretty printing source code; its main advantages over other libraries are the ability to automatically track the source locations associated with pretty printed values and output appropriate #line pragmas and the use of Text for output.

Synopsis

The Pretty type class for pretty printing

class Pretty a where #

Minimal complete definition

Methods

ppr :: a -> Doc #

pprPrec :: Int -> a -> Doc #

pprList :: [a] -> Doc #

Instances

 # Methodsppr :: Bool -> Doc #pprPrec :: Int -> Bool -> Doc #pprList :: [Bool] -> Doc # # Methodsppr :: Char -> Doc #pprPrec :: Int -> Char -> Doc #pprList :: [Char] -> Doc # # Methodsppr :: Double -> Doc #pprPrec :: Int -> Double -> Doc #pprList :: [Double] -> Doc # # Methodsppr :: Float -> Doc #pprPrec :: Int -> Float -> Doc #pprList :: [Float] -> Doc # # Methodsppr :: Int -> Doc #pprPrec :: Int -> Int -> Doc #pprList :: [Int] -> Doc # # Methodsppr :: Int8 -> Doc #pprPrec :: Int -> Int8 -> Doc #pprList :: [Int8] -> Doc # # Methodsppr :: Int16 -> Doc #pprPrec :: Int -> Int16 -> Doc #pprList :: [Int16] -> Doc # # Methodsppr :: Int32 -> Doc #pprPrec :: Int -> Int32 -> Doc #pprList :: [Int32] -> Doc # # Methodsppr :: Int64 -> Doc #pprPrec :: Int -> Int64 -> Doc #pprList :: [Int64] -> Doc # # Methodsppr :: Integer -> Doc #pprPrec :: Int -> Integer -> Doc #pprList :: [Integer] -> Doc # # Methodsppr :: Word8 -> Doc #pprPrec :: Int -> Word8 -> Doc #pprList :: [Word8] -> Doc # # Methodsppr :: Word16 -> Doc #pprPrec :: Int -> Word16 -> Doc #pprList :: [Word16] -> Doc # # Methodsppr :: Word32 -> Doc #pprPrec :: Int -> Word32 -> Doc #pprList :: [Word32] -> Doc # # Methodsppr :: Word64 -> Doc #pprPrec :: Int -> Word64 -> Doc #pprList :: [Word64] -> Doc # Pretty () # Methodsppr :: () -> Doc #pprPrec :: Int -> () -> Doc #pprList :: [()] -> Doc # # Methodsppr :: Pos -> Doc #pprPrec :: Int -> Pos -> Doc #pprList :: [Pos] -> Doc # # Methodsppr :: Loc -> Doc #pprPrec :: Int -> Loc -> Doc #pprList :: [Loc] -> Doc # # Methodsppr :: Text -> Doc #pprPrec :: Int -> Text -> Doc #pprList :: [Text] -> Doc # # Methodsppr :: Text -> Doc #pprPrec :: Int -> Text -> Doc #pprList :: [Text] -> Doc # # Methodsppr :: Doc -> Doc #pprPrec :: Int -> Doc -> Doc #pprList :: [Doc] -> Doc # Pretty a => Pretty [a] # Methodsppr :: [a] -> Doc #pprPrec :: Int -> [a] -> Doc #pprList :: [[a]] -> Doc # Pretty a => Pretty (Maybe a) # Methodsppr :: Maybe a -> Doc #pprPrec :: Int -> Maybe a -> Doc #pprList :: [Maybe a] -> Doc # (Integral a, Pretty a) => Pretty (Ratio a) # Methodsppr :: Ratio a -> Doc #pprPrec :: Int -> Ratio a -> Doc #pprList :: [Ratio a] -> Doc # (RealFloat a, Pretty a) => Pretty (Complex a) # Methodsppr :: Complex a -> Doc #pprPrec :: Int -> Complex a -> Doc #pprList :: [Complex a] -> Doc # Pretty a => Pretty (Set a) # Methodsppr :: Set a -> Doc #pprPrec :: Int -> Set a -> Doc #pprList :: [Set a] -> Doc # Pretty x => Pretty (L x) # Methodsppr :: L x -> Doc #pprPrec :: Int -> L x -> Doc #pprList :: [L x] -> Doc # (Pretty a, Pretty b) => Pretty (a, b) # Methodsppr :: (a, b) -> Doc #pprPrec :: Int -> (a, b) -> Doc #pprList :: [(a, b)] -> Doc # (Pretty k, Pretty v) => Pretty (Map k v) # Methodsppr :: Map k v -> Doc #pprPrec :: Int -> Map k v -> Doc #pprList :: [Map k v] -> Doc # (Pretty a, Pretty b, Pretty c) => Pretty (a, b, c) # Methodsppr :: (a, b, c) -> Doc #pprPrec :: Int -> (a, b, c) -> Doc #pprList :: [(a, b, c)] -> Doc # (Pretty a, Pretty b, Pretty c, Pretty d) => Pretty (a, b, c, d) # Methodsppr :: (a, b, c, d) -> Doc #pprPrec :: Int -> (a, b, c, d) -> Doc #pprList :: [(a, b, c, d)] -> Doc # (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e) => Pretty (a, b, c, d, e) # Methodsppr :: (a, b, c, d, e) -> Doc #pprPrec :: Int -> (a, b, c, d, e) -> Doc #pprList :: [(a, b, c, d, e)] -> Doc # (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f) => Pretty (a, b, c, d, e, f) # Methodsppr :: (a, b, c, d, e, f) -> Doc #pprPrec :: Int -> (a, b, c, d, e, f) -> Doc #pprList :: [(a, b, c, d, e, f)] -> Doc # (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g) => Pretty (a, b, c, d, e, f, g) # Methodsppr :: (a, b, c, d, e, f, g) -> Doc #pprPrec :: Int -> (a, b, c, d, e, f, g) -> Doc #pprList :: [(a, b, c, d, e, f, g)] -> Doc # (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) # Methodsppr :: (a, b, c, d, e, f, g, h) -> Doc #pprPrec :: Int -> (a, b, c, d, e, f, g, h) -> Doc #pprList :: [(a, b, c, d, e, f, g, h)] -> Doc # (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h, Pretty i) => Pretty (a, b, c, d, e, f, g, h, i) # Methodsppr :: (a, b, c, d, e, f, g, h, i) -> Doc #pprPrec :: Int -> (a, b, c, d, e, f, g, h, i) -> Doc #pprList :: [(a, b, c, d, e, f, g, h, i)] -> Doc # (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h, Pretty i, Pretty j) => Pretty (a, b, c, d, e, f, g, h, i, j) # Methodsppr :: (a, b, c, d, e, f, g, h, i, j) -> Doc #pprPrec :: Int -> (a, b, c, d, e, f, g, h, i, j) -> Doc #pprList :: [(a, b, c, d, e, f, g, h, i, j)] -> Doc # (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h, Pretty i, Pretty j, Pretty k) => Pretty (a, b, c, d, e, f, g, h, i, j, k) # Methodsppr :: (a, b, c, d, e, f, g, h, i, j, k) -> Doc #pprPrec :: Int -> (a, b, c, d, e, f, g, h, i, j, k) -> Doc #pprList :: [(a, b, c, d, e, f, g, h, i, j, k)] -> Doc # (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h, Pretty i, Pretty j, Pretty k, Pretty l) => Pretty (a, b, c, d, e, f, g, h, i, j, k, l) # Methodsppr :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Doc #pprPrec :: Int -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Doc #pprList :: [(a, b, c, d, e, f, g, h, i, j, k, l)] -> Doc # (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h, Pretty i, Pretty j, Pretty k, Pretty l, Pretty m) => Pretty (a, b, c, d, e, f, g, h, i, j, k, l, m) # Methodsppr :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Doc #pprPrec :: Int -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Doc #pprList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m)] -> Doc # (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h, Pretty i, Pretty j, Pretty k, Pretty l, Pretty m, Pretty n) => Pretty (a, b, c, d, e, f, g, h, i, j, k, l, m, n) # Methodsppr :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Doc #pprPrec :: Int -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Doc #pprList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] -> Doc # (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f, Pretty g, Pretty h, Pretty i, Pretty j, Pretty k, Pretty l, Pretty m, Pretty n, Pretty o) => Pretty (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) # Methodsppr :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Doc #pprPrec :: Int -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Doc #pprList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] -> Doc #

pprint :: (Pretty a, MonadIO m) => a -> m () #

The pprint function outputs a value of any type that is an instance of Pretty to the standard output device by calling ppr and adding a newline.