-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell2010 structured text formatting -- -- A modern take on structured text formatting, also known as -- pretty-printing. Based on the classic pretty package by Hughes, -- Peyton-Jones et al. @package prettify @version 1.0 -- | This library was based on The Design of a Pretty-printing -- Library by Jeuring and Meijer. -- -- Heavily modified by Simon Peyton Jones (December 1996). -- -- Lightly modified by Hans Hoglund (October 2012). module Text.Pretty -- | Class of types that can be pretty-printed. -- -- The Pretty class is similar to Show, but converts values to -- Printers instead of Strings. A printer is essentially -- a string with some extra structural information such as length and -- indentation. -- -- Note that the instances for primitive types, lists and tuples all -- satisfy -- --
--   (show . pretty) x == show x
--   
class Pretty a where prettyList = brackets . sepBy (char ',') . map pretty pretty :: Pretty a => a -> Printer prettyList :: Pretty a => [a] -> Printer -- | The abstract type of printers. data Printer -- | A printer of height and width 1, containing a literal character. char :: Char -> Printer -- | A printer of height 1 containing a literal string. string -- satisfies the following laws: -- -- -- -- The side condition on the last law is necessary because -- string "" has height 1, while empty has no -- height. string :: String -> Printer -- | Some string with any width. (string s = sizedText (length s) -- s) sizedText :: Int -> String -> Printer -- | Some string, but without any width. Use for non-printing string such -- as a HTML or Latex tags zeroWidthText :: String -> Printer int :: Int -> Printer integer :: Integer -> Printer float :: Float -> Printer double :: Double -> Printer rational :: Rational -> Printer -- | The empty printer, with no height and no width. empty is the -- identity for <>, <+>, </> and -- <//>, and anywhere in the argument list for sep, -- hcat, hsep, vcat, fcat etc. empty :: Printer -- | Beside. <> is associative, with identity empty. (<->) :: Printer -> Printer -> Printer -- | Beside, separated by space, unless one of the arguments is -- empty. <+> is associative, with identity -- empty. (<+>) :: Printer -> Printer -> Printer -- | List version of <>. hcat :: [Printer] -> Printer -- | List version of <+>. hsep :: [Printer] -> Printer -- | Above, except that if the last line of the first argument stops at -- least one position before the first line of the second begins, these -- two lines are overlapped. For example: -- --
--   string "hi" </> nest 5 (string "there")
--   
-- -- lays out as -- --
--   hi   there
--   
-- -- rather than -- --
--   hi
--        there
--   
-- -- </> is associative, with identity empty, and also -- satisfies -- -- () :: Printer -> Printer -> Printer -- | Above, with no overlapping. <//> is associative, with -- identity empty. () :: Printer -> Printer -> Printer -- | List version of </>. vcat :: [Printer] -> Printer -- | Either hsep or vcat. sep :: [Printer] -> Printer -- | Either hcat or vcat. cat :: [Printer] -> Printer -- | "Paragraph fill" version of sep. fsep :: [Printer] -> Printer -- | "Paragraph fill" version of cat. fcat :: [Printer] -> Printer -- | Wrap printer in the given characters. wrap :: Char -> Char -> Printer -> Printer -- | Wrap printer in (...) parens :: Printer -> Printer -- | Wrap printer in [...] brackets :: Printer -> Printer -- | Wrap printer in {...} braces :: Printer -> Printer -- | Wrap printer in '...' quotes :: Printer -> Printer -- | Wrap printer in "..." doubleQuotes :: Printer -> Printer -- | Nest (or indent) a printer by a given number of positions (which may -- also be negative). nest satisfies the laws: -- -- -- -- The side condition on the last law is needed because empty is a -- left identity for <>. nest :: Int -> Printer -> Printer -- |
--   hang d1 n d2 = sep [d1, nest n d2]
--   
hang :: Printer -> Int -> Printer -> Printer -- | Join with separator. -- --
--   sepBy q [x1,x2..xn] = x1 <> q <> x2 <> q .. xn.
--   
sepBy :: Printer -> [Printer] -> Printer -- | Join with initiator. -- --
--   initBy q [x1,x2..xn] = q <> x1 <> q <> x2 <> q .. xn.
--   
initBy :: Printer -> [Printer] -> Printer -- | Join with terminator. -- --
--   termBy q [x1,x2..xn] = x1 <> q <> x2 <> q .. xn <> q.
--   
termBy :: Printer -> [Printer] -> Printer -- | Join with separator followed by space. -- --
--   sepByS q [x1,x2..xn] = x1 <> q <+> x2 <> q <+>.. xn.
--   
sepByS :: Printer -> [Printer] -> Printer -- | Join with initiator followed by space. -- --
--   initByS q [x1,x2..xn] = q <+> x1 <> q <+> x2 <> q <+> .. xn.
--   
initByS :: Printer -> [Printer] -> Printer -- | Join with terminator followed by space. -- --
--   termByS q [x1,x2..xn] = x1 <> q <+> x2 <> q <+> .. xn <> q.
--   
termByS :: Printer -> [Printer] -> Printer -- | Returns True if the printer is empty isEmpty :: Printer -> Bool -- | Render the Printer to a String using the default -- Style. runPrinter :: Printer -> String -- | Rendering mode. data Mode -- | Normal PageMode :: Mode -- | With zig-zag cuts ZigZagMode :: Mode -- | No indentation, infinitely long lines LeftMode :: Mode -- | All on one line OneLineMode :: Mode -- | A printing style. data Style Style :: Mode -> Int -> Float -> Style -- | The printing mode mode :: Style -> Mode -- | Length of line, in chars lineLength :: Style -> Int -- | Ratio of ribbon length to line length ribbonsPerLine :: Style -> Float -- | The default style (mode=PageMode, lineLength=100, -- ribbonsPerLine=1.5). style :: Style -- | Render the Printer to a String using the given -- Style. runPrinterStyle :: Style -> Printer -> String instance Show Printer instance IsString Printer instance Monoid Printer instance Semigroup Printer instance (Pretty a, Integral a) => Pretty (Ratio a) instance Pretty a => Pretty (Maybe a) instance Pretty a => Pretty [a] instance (Pretty a, Pretty b) => Pretty (a, b) instance Pretty Integer instance Pretty Char instance Pretty Double instance Pretty Float instance Pretty Int instance Pretty () instance Pretty Printer