|
|
|
|
|
Description |
This module defines classes and functions for pretty-printing. It also
exports a number of helpful debugging and other utilities such as trace and panic.
The interface to this module is very similar to the standard Hughes-PJ pretty printing
module, except that it exports a number of additional functions that are rarely used,
and works over the SDoc type.
|
|
Synopsis |
|
|
|
|
Type classes
|
|
class Outputable a where | Source |
|
Class designating that some type has an SDoc representation
| | Methods | |
|
|
|
When we print a binder, we often want to print its type too.
The OutputableBndr class encapsulates this idea.
| | Methods | |
|
|
Pretty printing combinators
|
|
|
|
|
|
|
Returns the seperated concatenation of the pretty printed things.
|
|
|
Returns the comma-seperated concatenation of the pretty printed things.
|
|
|
Returns the comma-seperated concatenation of the quoted pretty printed things.
[x,y,z] ==> `x', `y', `z'
|
|
|
:: | | => a -> SDoc | The things to be pretty printed
| -> [a] | SDoc where the things have been pretty printed,
comma-separated and finally packed into a paragraph.
| -> SDoc | |
|
|
|
|
|
Indent SDoc some specified amount
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Join two SDoc together horizontally without a gap
|
|
|
Join two SDoc together horizontally with a gap between them
|
|
|
Concatenate SDoc horizontally
|
|
|
Concatenate SDoc horizontally with a space between each one
|
|
|
Join two SDoc together vertically; if there is
no vertical overlap it dovetails the two onto one line
|
|
|
Join two SDoc together vertically
|
|
|
Concatenate SDoc vertically with dovetailing
|
|
|
Separate: is either like hsep or like vcat, depending on what fits
|
|
|
Catenate: is either like hcat or like vcat, depending on what fits
|
|
|
A paragraph-fill combinator. It's much like sep, only it
keeps fitting things on one line until it can't fit any more.
|
|
|
This behaves like fsep, but it uses <> for horizontal conposition rather than <+>
|
|
|
:: SDoc | The header
| -> Int | Amount to indent the hung body
| -> SDoc | The hung body, indented and placed below the header
| -> SDoc | |
|
|
|
:: SDoc | The punctuation
| -> [SDoc] | The list that will have punctuation added between every adjacent pair of elements
| -> [SDoc] | Punctuated list
|
|
|
|
|
|
|
|
Converts an integer to a verbal index:
speakNth 1 = text "first"
speakNth 5 = text "fifth"
speakNth 21 = text "21st"
|
|
|
Converts a strictly positive integer into a number of times:
speakNTimes 1 = text "once"
speakNTimes 2 = text "twice"
speakNTimes 4 = text "4 times"
|
|
|
Converts an integer to a verbal multiplicity:
speakN 0 = text "none"
speakN 5 = text "five"
speakN 10 = text "10"
|
|
|
Converts an integer and object description to a statement about the
multiplicity of those objects:
speakNOf 0 (text "melon") = text "no melons"
speakNOf 1 (text "melon") = text "one melon"
speakNOf 3 (text "melon") = text "three melons"
|
|
|
Determines the pluralisation suffix appropriate for the length of a list:
plural [] = char 's'
plural ["Hello"] = empty
plural ["Hello", "World"] = char 's'
|
|
Converting SDoc into strings and outputing it
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Special combinator for showing character literals.
|
|
|
Special combinator for showing string literals.
|
|
|
|
|
|
|
|
Controlling the style in which output is printed
|
|
|
BindingSite is used to tell the thing that prints binder what
language construct is binding the identifier. This can be used
to decide how much info to print.
| Constructors | LambdaBind | | CaseBind | | LetBind | |
|
|
|
|
|
|
|
|
type PrintUnqualified = (QueryQualifyName, QueryQualifyModule) | Source |
|
|
|
|
|
|
|
Constructors | NameUnqual | | NameQual ModuleName | | NameNotInScope1 | | NameNotInScope2 | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Style for printing error messages
|
|
|
|
|
|
|
|
|
|
|
|
|
Error handling and debugging utilities
|
|
|
Throw an exception saying bug in GHC
|
|
|
Panic with an assertation failure, recording the given file and line number.
Should typically be accessed with the ASSERT family of macros
|
|
|
Specialization of pprPanic that can be safely used with FastInt
|
|
|
Throw an exception saying bug in pgm being compiled (used for unusual program errors)
|
|
|
If debug output is on, show some SDoc on the screen
|
|
|
Just warn about an assertion failure, recording the given file and line number.
Should typically be accessed with the WARN macros
|
|
|
When called, trace outputs the string in its first argument, before
returning the second argument as its result. The trace function is not
referentially transparent, and should only be used for debugging, or for
monitoring execution. Some implementations of trace may decorate the string
that's output to indicate that you're tracing. The function is implemented on
top of putTraceMsg.
|
|
|
|
|
|
|
|
|
|
Produced by Haddock version 2.6.0 |