Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
This module contains functions for pretty printing.
We are using the Pretty
type class from the 'wl-pprint-text' package.
Synopsis
- (<$$>) :: Doc -> Doc -> Doc
- (<++>) :: Doc -> Doc -> Doc
- (<+>) :: Doc -> Doc -> Doc
- (<//>) :: Doc -> Doc -> Doc
- (</>) :: Doc -> Doc -> Doc
- align :: Doc -> Doc
- angles :: Doc -> Doc
- backslash :: Doc
- beside :: Doc -> Doc -> Doc
- bool :: Bool -> Doc
- braces :: Doc -> Doc
- brackets :: Doc -> Doc
- cat :: [Doc] -> Doc
- char :: Char -> Doc
- colon :: Doc
- column :: (Int -> Doc) -> Doc
- comma :: Doc
- displayB :: SimpleDoc -> Builder
- displayIO :: Handle -> SimpleDoc -> IO ()
- displayT :: SimpleDoc -> Text
- displayTStrict :: SimpleDoc -> Text
- dot :: Doc
- double :: Double -> Doc
- dquote :: Doc
- dquotes :: Doc -> Doc
- empty :: Doc
- enclose :: Doc -> Doc -> Doc -> Doc
- encloseSep :: Doc -> Doc -> Doc -> [Doc] -> Doc
- equals :: Doc
- fill :: Int -> Doc -> Doc
- fillBreak :: Int -> Doc -> Doc
- fillCat :: [Doc] -> Doc
- fillSep :: [Doc] -> Doc
- float :: Float -> Doc
- group :: Doc -> Doc
- hPutDoc :: Handle -> Doc -> IO ()
- hang :: Int -> Doc -> Doc
- hcat :: [Doc] -> Doc
- hsep :: [Doc] -> Doc
- indent :: Int -> Doc -> Doc
- int :: Int -> Doc
- integer :: Integer -> Doc
- isEmpty :: Doc -> Bool
- langle :: Doc
- lbrace :: Doc
- lbracket :: Doc
- line :: Doc
- linebreak :: Doc
- list :: [Doc] -> Doc
- lparen :: Doc
- nest :: Int -> Doc -> Doc
- nesting :: (Int -> Doc) -> Doc
- parens :: Doc -> Doc
- punctuate :: Doc -> [Doc] -> [Doc]
- putDoc :: Doc -> IO ()
- rangle :: Doc
- rational :: Rational -> Doc
- rbrace :: Doc
- rbracket :: Doc
- renderCompact :: Doc -> SimpleDoc
- renderOneLine :: Doc -> SimpleDoc
- renderPretty :: Float -> Int -> Doc -> SimpleDoc
- rparen :: Doc
- semi :: Doc
- semiBraces :: [Doc] -> Doc
- sep :: [Doc] -> Doc
- softbreak :: Doc
- softline :: Doc
- space :: Doc
- spacebreak :: Doc
- squote :: Doc
- squotes :: Doc -> Doc
- string :: Text -> Doc
- stringStrict :: Text -> Doc
- text :: Text -> Doc
- textStrict :: Text -> Doc
- tupled :: [Doc] -> Doc
- vcat :: [Doc] -> Doc
- vsep :: [Doc] -> Doc
- width :: Doc -> (Int -> Doc) -> Doc
- data Doc
- class Pretty a where
- pretty :: a -> Doc
- prettyList :: [a] -> Doc
- data SimpleDoc
- prettySeparated :: Pretty a => Doc -> [a] -> Doc
- prettyMaybe :: (Pretty a, Pretty b) => a -> Maybe b -> Doc
- prettyString :: String -> Doc
- prettyText :: String -> Doc
- prettyLines :: String -> Doc
- data TrailingLine a
- renderPretty' :: Pretty a => a -> SimpleDoc
- putPretty :: Pretty a => a -> IO ()
- putPrettyLn :: Pretty a => a -> IO ()
- hPutPretty :: Pretty a => Handle -> a -> IO ()
- hPutPrettyLn :: Pretty a => Handle -> a -> IO ()
- writePrettyFile :: Pretty a => FilePath -> a -> IO ()
- showPretty :: Pretty a => a -> String
Documentation
displayTStrict :: SimpleDoc -> Text #
renderCompact :: Doc -> SimpleDoc #
renderOneLine :: Doc -> SimpleDoc #
semiBraces :: [Doc] -> Doc #
spacebreak :: Doc #
stringStrict :: Text -> Doc #
textStrict :: Text -> Doc #
Instances
Pretty Bool | |
Defined in Text.PrettyPrint.Leijen.Text | |
Pretty Char | |
Defined in Text.PrettyPrint.Leijen.Text | |
Pretty Double | |
Defined in Text.PrettyPrint.Leijen.Text | |
Pretty Float | |
Defined in Text.PrettyPrint.Leijen.Text | |
Pretty Int | |
Defined in Text.PrettyPrint.Leijen.Text | |
Pretty Integer | |
Defined in Text.PrettyPrint.Leijen.Text | |
Pretty () | |
Defined in Text.PrettyPrint.Leijen.Text | |
Pretty Text | |
Defined in Text.PrettyPrint.Leijen.Text | |
Pretty Text | |
Defined in Text.PrettyPrint.Leijen.Text | |
Pretty Sentence Source # | Sentences often need to be pretty printed in the tests and when writing the generated Coq code to the console or a file. |
Defined in FreeC.Backend.Coq.Pretty | |
Pretty Term Source # | Terms often need to be pretty printed in the tests. |
Defined in FreeC.Backend.Coq.Pretty | |
Pretty Doc | |
Defined in Text.PrettyPrint.Leijen.Text | |
Pretty SrcSpan Source # | Pretty instance for a source span that displays the filename and the start and end position of the source span. If the source span spans only a single line, the end position is omitted. |
Defined in FreeC.IR.SrcSpan | |
Pretty SrcFile Source # | Pretty instance for a source file that displays the filename. |
Defined in FreeC.IR.SrcSpan | |
Pretty Message Source # | Pretty instance for messages. The format of the messages is based on the format used by GHC: [file]:[line]:[column]: [severity]: [message-contents] | [line] | [line of code ... culprit ... ] | ^^^^^^^ If no location information is attached to the message, a place holder is text displayed instead of the filename, and start position and no code snippet will be shown. Lists of messages are separated by a newline. |
Defined in FreeC.Monad.Reporter | |
Pretty Severity Source # | Pretty instance for message severity levels. |
Defined in FreeC.Monad.Reporter | |
Pretty DeclIdent Source # | Pretty instance for names of declarations. |
Defined in FreeC.IR.Syntax.Name | |
Pretty QName Source # | Pretty instance for qualifiable identifiers and symbols. |
Defined in FreeC.IR.Syntax.Name | |
Pretty Name Source # | Pretty instance for identifiers and symbols. |
Defined in FreeC.IR.Syntax.Name | |
Pretty Type Source # | Pretty instance for type expressions. |
Defined in FreeC.IR.Syntax.Type | |
Pretty TypeVarDecl Source # | Pretty instance for type variable declaration. |
Defined in FreeC.IR.Syntax.TypeVarDecl pretty :: TypeVarDecl -> Doc # prettyList :: [TypeVarDecl] -> Doc # | |
Pretty TypeScheme Source # | Pretty instance for type schemes. |
Defined in FreeC.IR.Syntax.TypeScheme pretty :: TypeScheme -> Doc # prettyList :: [TypeScheme] -> Doc # | |
Pretty ConDecl Source # | Pretty instance for data constructor declarations. |
Defined in FreeC.IR.Syntax.TypeDecl | |
Pretty TypeDecl Source # | Pretty instance for type declarations. |
Defined in FreeC.IR.Syntax.TypeDecl | |
Pretty Pragma Source # | Pretty instance for custom |
Defined in FreeC.IR.Syntax.Pragma | |
Pretty Comment Source # | Pretty instance for comments. |
Defined in FreeC.IR.Syntax.Pragma | |
Pretty Bind Source # | Pretty instance for |
Defined in FreeC.IR.Syntax.Expr | |
Pretty VarPat Source # | Pretty instance for variable patterns. |
Defined in FreeC.IR.Syntax.Expr | |
Pretty ConPat Source # | Pretty instance for constructor patterns. |
Defined in FreeC.IR.Syntax.Expr | |
Pretty Alt Source # | Pretty instance for |
Defined in FreeC.IR.Syntax.Expr | |
Pretty Expr Source # | Pretty instance for expressions. If the expression contains type annotations, the output quickly becomes practically unreadable. Consider stripping type annotations before pretty printing (see FreeC.IR.Strip) to improve readability. |
Defined in FreeC.IR.Syntax.Expr | |
Pretty FuncDecl Source # | Pretty instance for function declarations. |
Defined in FreeC.IR.Syntax.FuncDecl | |
Pretty TypeSig Source # | Pretty instance for type signatures. |
Defined in FreeC.IR.Syntax.FuncDecl | |
Pretty TopLevelDecl Source # | Pretty instance for top-level declarations. |
Defined in FreeC.IR.Syntax.Module pretty :: TopLevelDecl -> Doc # prettyList :: [TopLevelDecl] -> Doc # | |
Pretty ImportDecl Source # | Pretty instance for import declarations. |
Defined in FreeC.IR.Syntax.Module pretty :: ImportDecl -> Doc # prettyList :: [ImportDecl] -> Doc # | |
Pretty Pos Source # | Pretty prints a position. |
Defined in FreeC.IR.Subterm | |
Pretty Keyword Source # | Pretty prints a keyword. |
Defined in FreeC.Frontend.IR.Token | |
Pretty Token Source # | Pretty prints a token. |
Defined in FreeC.Frontend.IR.Token | |
Pretty Declaration Source # |
|
Defined in FreeC.Backend.Agda.Pretty | |
Pretty Expr Source # |
|
Defined in FreeC.Backend.Agda.Pretty | |
Pretty a => Pretty [a] | |
Defined in Text.PrettyPrint.Leijen.Text | |
Pretty a => Pretty (Maybe a) | |
Defined in Text.PrettyPrint.Leijen.Text | |
Pretty a => Pretty (TrailingLine a) Source # | Pretty prints the wrapped value of a |
Defined in FreeC.Pretty pretty :: TrailingLine a -> Doc # prettyList :: [TrailingLine a] -> Doc # | |
Pretty contents => Pretty (ModuleOf [contents]) Source # | Pretty instance for modules. |
Defined in FreeC.IR.Syntax.Module | |
Pretty (Module l) Source # | Pretty instance for module nodes of Haskell Source Extensions AST. |
Defined in FreeC.Frontend.Haskell.Pretty | |
Gallina a => Pretty (PrettyCoq a) Source # | Pretty instance for nodes of the Coq AST. When pretty printing a list of nodes, the individual documents are concatenated with newlines. |
Defined in FreeC.Backend.Coq.Pretty | |
Pretty decl => Pretty (DependencyComponent decl) Source # | Pretty instance that pretty prints the declarations of a strongly connected component. Each declaration is on its own line and indented by two spaces. The first line of the document indicates whether the component was recursive or not. |
Defined in FreeC.IR.DependencyGraph pretty :: DependencyComponent decl -> Doc # prettyList :: [DependencyComponent decl] -> Doc # | |
Pretty (DependencyGraph node) Source # | Pretty instance that converts a dependency graph to the DOT format. |
Defined in FreeC.IR.DependencyGraph pretty :: DependencyGraph node -> Doc # prettyList :: [DependencyGraph node] -> Doc # | |
Pretty a => Pretty (Subst a) Source # | Substitutions can be pretty printed for testing purposes. |
Defined in FreeC.IR.Subst | |
(Pretty a, Pretty b) => Pretty (a, b) | |
Defined in Text.PrettyPrint.Leijen.Text | |
(Pretty a, Pretty b, Pretty c) => Pretty (a, b, c) | |
Defined in Text.PrettyPrint.Leijen.Text |
Pretty Printing
prettySeparated :: Pretty a => Doc -> [a] -> Doc Source #
Pretty prints a list of pretty printable values by concatenating their documents with the given separator in between.
prettyString :: String -> Doc Source #
Pretty prints a string without automatic newlines if the string does not fit onto the page.
prettyText :: String -> Doc Source #
Pretty prints a string such that long lines that don't fit the page are automatically broken between two words.
prettyLines :: String -> Doc Source #
Pretty prints each line of the given string using prettyText
and
concatenates the resulting documents vertically.
Trailing Lines
data TrailingLine a Source #
A pretty printable value with a trailing newline.
Instances
Pretty a => Pretty (TrailingLine a) Source # | Pretty prints the wrapped value of a |
Defined in FreeC.Pretty pretty :: TrailingLine a -> Doc # prettyList :: [TrailingLine a] -> Doc # |
Rendering
renderPretty' :: Pretty a => a -> SimpleDoc Source #
Pretty prints a value with a maximum line length of 120
characters of
which 80
are allowed to be non-indentation characters.
Output
putPrettyLn :: Pretty a => a -> IO () Source #
Prints a pretty printable value to stdout
with trailing newline.
hPutPretty :: Pretty a => Handle -> a -> IO () Source #
Prints a pretty printable value to the given file handle.
hPutPrettyLn :: Pretty a => Handle -> a -> IO () Source #
Prints a pretty printable value to the given file handle and adds a trailing newline.
writePrettyFile :: Pretty a => FilePath -> a -> IO () Source #
Writes a pretty printable value to the file located at the given path.
There is always a trailing newline at the end of the file.
Conversion
showPretty :: Pretty a => a -> String Source #
Converts a pretty printable value to a string.