futhark-0.25.15: An optimising compiler for a functional, array-oriented language.
Safe HaskellSafe-Inferred
LanguageGHC2021

Futhark.Util.Pretty

Description

A re-export of the prettyprinting library, along with some convenience functions.

Synopsis

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.

prettyText :: Pretty a => a -> Text Source #

Prettyprint a value to a Text, appropriately wrapped.

prettyTextOneLine :: Pretty a => a -> Text Source #

Prettyprint a value to a Text 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.

docString :: Doc a -> String Source #

Convert a Doc to a String, through docText. Intended for debugging.

Rendering to terminal

putDoc :: Doc AnsiStyle -> IO () Source #

Like hPutDoc, but to stdout.

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.

putDocLn :: Doc AnsiStyle -> IO () Source #

Like putDoc, but with a final newline.

hPutDocLn :: Handle -> Doc AnsiStyle -> IO () Source #

Like hPutDoc, but with a final newline.

Building blocks

data Color #

Constructors

Black 
Red 
Green 
Yellow 
Blue 
Magenta 
Cyan 
White 

Instances

Instances details
Show Color 
Instance details

Defined in Prettyprinter.Render.Terminal.Internal

Eq Color 
Instance details

Defined in Prettyprinter.Render.Terminal.Internal

Methods

(==) :: Color -> Color -> Bool Source #

(/=) :: Color -> Color -> Bool Source #

Ord Color 
Instance details

Defined in Prettyprinter.Render.Terminal.Internal

apply :: [Doc a] -> Doc a Source #

The document apply ds separates ds 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.

annot :: [Doc a] -> Doc a -> Doc a Source #

Stack and prepend a list of Docs to another Doc, separated by a linebreak. If the list is empty, the second Doc will be returned without a preceding linebreak.

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.

commastack :: [Doc a] -> Doc a Source #

Like commasep, but a newline after every comma.

commasep :: [Doc a] -> Doc a Source #

Separate with commas.

semistack :: [Doc a] -> Doc a Source #

Separate with semicolons and newlines.

stack :: [Doc a] -> Doc a Source #

Separate with linebreaks.

parensIf :: Bool -> Doc a -> Doc a Source #

The document parensIf p d encloses the document d in parenthesis if p is True, and otherwise yields just d.

ppTuple' :: [Doc a] -> Doc a Source #

Operators

(</>) :: Doc a -> Doc a -> Doc a Source #

Orphan instances

Pretty Half Source # 
Instance details

Methods

pretty :: Half -> Doc ann Source #

prettyList :: [Half] -> Doc ann Source #