Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
A re-export of the prettyprinting library, along with some convenience functions.
Synopsis
- prettyTuple :: Pretty a => [a] -> Text
- prettyTupleLines :: Pretty a => [a] -> Text
- prettyString :: Pretty a => a -> String
- prettyStringOneLine :: Pretty a => a -> String
- prettyText :: Pretty a => a -> Text
- prettyTextOneLine :: Pretty a => a -> Text
- docText :: Doc a -> Text
- docTextForHandle :: Handle -> Doc AnsiStyle -> IO Text
- docString :: Doc a -> String
- putDoc :: Doc AnsiStyle -> IO ()
- hPutDoc :: Handle -> Doc AnsiStyle -> IO ()
- putDocLn :: Doc AnsiStyle -> IO ()
- hPutDocLn :: Handle -> Doc AnsiStyle -> IO ()
- module Prettyprinter
- module Prettyprinter.Symbols.Ascii
- data Color
- data AnsiStyle
- bold :: AnsiStyle
- color :: Color -> AnsiStyle
- bgColor :: Color -> AnsiStyle
- colorDull :: Color -> AnsiStyle
- bgColorDull :: Color -> AnsiStyle
- italicized :: AnsiStyle
- underlined :: AnsiStyle
- apply :: [Doc a] -> Doc a
- oneLine :: Doc a -> Doc a
- annot :: [Doc a] -> Doc a -> Doc a
- nestedBlock :: Doc a -> Doc a -> Doc a -> Doc a
- textwrap :: Text -> Doc a
- shorten :: Doc a -> Doc b
- commastack :: [Doc a] -> Doc a
- commasep :: [Doc a] -> Doc a
- semistack :: [Doc a] -> Doc a
- stack :: [Doc a] -> Doc a
- parensIf :: Bool -> Doc a -> Doc a
- ppTuple' :: [Doc a] -> Doc a
- ppTupleLines' :: [Doc a] -> Doc a
- (</>) :: Doc a -> Doc a -> Doc a
Rendering to texts
prettyTuple :: Pretty a => [a] -> Text Source #
Prettyprint a list enclosed in curly braces.
prettyTupleLines :: Pretty a => [a] -> Text Source #
Like prettyTuple
, but put a linebreak after every element.
prettyString :: Pretty a => a -> String Source #
Prettyprint a value to a String
, appropriately wrapped.
prettyStringOneLine :: Pretty a => a -> String Source #
Prettyprint a value to a String
on a single line.
docText :: Doc a -> Text Source #
Convert a Doc
to text. This ignores any annotations (i.e. it
will be non-coloured output).
docTextForHandle :: Handle -> Doc AnsiStyle -> IO Text Source #
Produce text suitable for printing on the given handle. This mostly means stripping any control characters if the handle is not a terminal.
Rendering to terminal
hPutDoc :: Handle -> Doc AnsiStyle -> IO () Source #
Print a doc with styling to the given file; stripping colors if the file does not seem to support such things.
Building blocks
module Prettyprinter
module Prettyprinter.Symbols.Ascii
Render the annotated document in a certain style. Styles not set in the annotation will use the style of the surrounding document, or the terminal’s default if none has been set yet.
style =color
Green
<>
bold
styledDoc =annotate
style "hello world"
Instances
Monoid AnsiStyle |
|
Semigroup AnsiStyle | Keep the first decision for each of foreground color, background color, boldness, italication, and underlining. If a certain style is not set, the terminal’s default will be used. Example:
is red because the first color wins, and not bold because (or if) that’s the terminal’s default. |
Show AnsiStyle | |
Eq AnsiStyle | |
Ord AnsiStyle | |
Defined in Prettyprinter.Render.Terminal.Internal |
bgColorDull :: Color -> AnsiStyle #
Style the background with a dull color.
italicized :: AnsiStyle #
Render in italics.
underlined :: AnsiStyle #
Render underlined.
apply :: [Doc a] -> Doc a Source #
The document
separates apply
dsds
with commas and encloses them with
parentheses.
oneLine :: Doc a -> Doc a Source #
Make sure that the given document is printed on just a single line.
nestedBlock :: Doc a -> Doc a -> Doc a -> Doc a Source #
Surround the given document with enclosers and add linebreaks and indents.
textwrap :: Text -> Doc a Source #
Splits the string into words and permits line breaks between all of them.
shorten :: Doc a -> Doc b Source #
Prettyprint on a single line up to at most some appropriate number of characters, with trailing ... if necessary. Used for error messages.
parensIf :: Bool -> Doc a -> Doc a Source #
The document
encloses the document parensIf
p dd
in parenthesis if
p
is True
, and otherwise yields just d
.
ppTupleLines' :: [Doc a] -> Doc a Source #