-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Pretty-printing library -- -- This package contains a pretty-printing library, a set of API's that -- provides a way to easily print out text in a consistent format of your -- choosing. This is useful for compilers and related tools. -- -- This library was originally designed by John Hughes's and has since -- been heavily modified by Simon Peyton Jones. @package pretty @version 1.1.1.2 -- | John Hughes's and Simon Peyton Jones's Pretty Printer Combinators -- -- Based on The Design of a Pretty-printing Library in Advanced -- Functional Programming, Johan Jeuring and Erik Meijer (eds), LNCS 925 -- http://www.cs.chalmers.se/~rjmh/Papers/pretty.ps module Text.PrettyPrint.HughesPJ -- | The abstract type of documents. A Doc represents a *set* of layouts. A -- Doc with no occurrences of Union or NoDoc represents just one layout. data Doc -- | The TextDetails data type -- -- A TextDetails represents a fragment of text that will be output at -- some point. data TextDetails -- | A single Char fragment Chr :: {-# UNPACK #-} !Char -> TextDetails -- | A whole String fragment Str :: String -> TextDetails -- | Used to represent a Fast String fragment but now deprecated and -- identical to the Str constructor. PStr :: String -> TextDetails -- | A document of height and width 1, containing a literal character. char :: Char -> Doc -- | A document of height 1 containing a literal string. text -- satisfies the following laws: -- --
-- -- The side condition on the last law is necessary because -- text "" has height 1, while empty has no -- height. text :: String -> Doc -- | Same as text. Used to be used for Bytestrings. ptext :: String -> Doc -- | Some text with any width. (text s = sizedText (length s) s) sizedText :: Int -> String -> Doc -- | Some text, but without any width. Use for non-printing text such as a -- HTML or Latex tags zeroWidthText :: String -> Doc int :: Int -> Doc integer :: Integer -> Doc float :: Float -> Doc double :: Double -> Doc rational :: Rational -> Doc semi :: Doc comma :: Doc colon :: Doc space :: Doc equals :: Doc lparen :: Doc rparen :: Doc lbrack :: Doc rbrack :: Doc lbrace :: Doc rbrace :: Doc parens :: Doc -> Doc brackets :: Doc -> Doc braces :: Doc -> Doc quotes :: Doc -> Doc doubleQuotes :: Doc -> Doc -- | The empty document, 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 :: Doc -- | Beside. <> is associative, with identity empty. (<>) :: Doc -> Doc -> Doc -- | Beside, separated by space, unless one of the arguments is -- empty. <+> is associative, with identity -- empty. (<+>) :: Doc -> Doc -> Doc -- | List version of <>. hcat :: [Doc] -> Doc -- | List version of <+>. hsep :: [Doc] -> Doc -- | 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: -- ---- text "hi" $$ nest 5 (text "there") ---- -- lays out as -- --
-- hi there ---- -- rather than -- --
-- hi -- there ---- -- $$ is associative, with identity empty, and also -- satisfies -- -- ($$) :: Doc -> Doc -> Doc -- | Above, with no overlapping. $+$ is associative, with identity -- empty. ($+$) :: Doc -> Doc -> Doc -- | List version of $$. vcat :: [Doc] -> Doc -- | Either hsep or vcat. sep :: [Doc] -> Doc -- | Either hcat or vcat. cat :: [Doc] -> Doc -- | "Paragraph fill" version of sep. fsep :: [Doc] -> Doc -- | "Paragraph fill" version of cat. fcat :: [Doc] -> Doc -- | Nest (or indent) a document by a given number of positions (which may -- also be negative). nest satisfies the laws: -- --
nest 0 x = x
nest k (nest k' x) = nest (k+k') -- x
nest k (x <> y) = nest k z -- <> nest k y
nest k (x $$ y) = nest k x $$ -- nest k y
nest k empty = empty
-- hang d1 n d2 = sep [d1, nest n d2] --hang :: Doc -> Int -> Doc -> Doc -- |
-- punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn-1 <> p, dn] --punctuate :: Doc -> [Doc] -> [Doc] -- | Returns True if the document is empty isEmpty :: Doc -> Bool -- | first returns its first argument if it is non-empty, -- otherwise its second. first :: Doc -> Doc -> Doc -- | Perform some simplification of a built up GDoc. reduceDoc :: Doc -> RDoc -- | Render the Doc to a String using the default Style. render :: Doc -> String -- | A rendering style. data Style Style :: Mode -> Int -> Float -> Style -- | The rendering 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 Doc to a String using the given Style. renderStyle :: Style -> Doc -> 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 -- | The general rendering interface. fullRender :: Mode -> Int -> Float -> (TextDetails -> a -> a) -> a -> Doc -> a instance [safe] NFData TextDetails instance [safe] NFData Doc instance [safe] Eq Doc instance [safe] Show Doc instance [safe] IsString Doc instance [safe] Monoid Doc -- | The default interface to the pretty-printing library. Provides a -- collection of pretty printer combinators. -- -- This module should be used as opposed to the -- Text.PrettyPrint.HughesPJ module. Both are equivalent though as -- this module simply re-exports the other. module Text.PrettyPrint -- | The abstract type of documents. A Doc represents a *set* of layouts. A -- Doc with no occurrences of Union or NoDoc represents just one layout. data Doc -- | A document of height and width 1, containing a literal character. char :: Char -> Doc -- | A document of height 1 containing a literal string. text -- satisfies the following laws: -- -- -- -- The side condition on the last law is necessary because -- text "" has height 1, while empty has no -- height. text :: String -> Doc -- | Same as text. Used to be used for Bytestrings. ptext :: String -> Doc -- | Some text with any width. (text s = sizedText (length s) s) sizedText :: Int -> String -> Doc -- | Some text, but without any width. Use for non-printing text such as a -- HTML or Latex tags zeroWidthText :: String -> Doc int :: Int -> Doc integer :: Integer -> Doc float :: Float -> Doc double :: Double -> Doc rational :: Rational -> Doc semi :: Doc comma :: Doc colon :: Doc space :: Doc equals :: Doc lparen :: Doc rparen :: Doc lbrack :: Doc rbrack :: Doc lbrace :: Doc rbrace :: Doc parens :: Doc -> Doc brackets :: Doc -> Doc braces :: Doc -> Doc quotes :: Doc -> Doc doubleQuotes :: Doc -> Doc -- | The empty document, 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 :: Doc -- | Beside. <> is associative, with identity empty. (<>) :: Doc -> Doc -> Doc -- | Beside, separated by space, unless one of the arguments is -- empty. <+> is associative, with identity -- empty. (<+>) :: Doc -> Doc -> Doc -- | List version of <>. hcat :: [Doc] -> Doc -- | List version of <+>. hsep :: [Doc] -> Doc -- | 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: -- --
-- text "hi" $$ nest 5 (text "there") ---- -- lays out as -- --
-- hi there ---- -- rather than -- --
-- hi -- there ---- -- $$ is associative, with identity empty, and also -- satisfies -- -- ($$) :: Doc -> Doc -> Doc -- | Above, with no overlapping. $+$ is associative, with identity -- empty. ($+$) :: Doc -> Doc -> Doc -- | List version of $$. vcat :: [Doc] -> Doc -- | Either hsep or vcat. sep :: [Doc] -> Doc -- | Either hcat or vcat. cat :: [Doc] -> Doc -- | "Paragraph fill" version of sep. fsep :: [Doc] -> Doc -- | "Paragraph fill" version of cat. fcat :: [Doc] -> Doc -- | Nest (or indent) a document by a given number of positions (which may -- also be negative). nest satisfies the laws: -- --
nest 0 x = x
nest k (nest k' x) = nest (k+k') -- x
nest k (x <> y) = nest k z -- <> nest k y
nest k (x $$ y) = nest k x $$ -- nest k y
nest k empty = empty
-- hang d1 n d2 = sep [d1, nest n d2] --hang :: Doc -> Int -> Doc -> Doc -- |
-- punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn-1 <> p, dn] --punctuate :: Doc -> [Doc] -> [Doc] -- | Returns True if the document is empty isEmpty :: Doc -> Bool -- | Render the Doc to a String using the default Style. render :: Doc -> String -- | A rendering style. data Style Style :: Mode -> Int -> Float -> Style -- | The rendering 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 Doc to a String using the given Style. renderStyle :: Style -> Doc -> String -- | The general rendering interface. fullRender :: Mode -> Int -> Float -> (TextDetails -> a -> a) -> a -> Doc -> a -- | 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 -- | The TextDetails data type -- -- A TextDetails represents a fragment of text that will be output at -- some point. data TextDetails -- | A single Char fragment Chr :: {-# UNPACK #-} !Char -> TextDetails -- | A whole String fragment Str :: String -> TextDetails -- | Used to represent a Fast String fragment but now deprecated and -- identical to the Str constructor. PStr :: String -> TextDetails