trait PrettyPrinterBase extends AnyRef
The interface of a pretty printer using combinators from Swierstra and Chitil (Linear, bounded, functional pretty-printing, Journal of Functional Programming, 19 (1), 2009) and Leijen's PPrint library. The latter is a version of Wadler's library which was inspired by an earlier library by Hughes.
- Source
- PrettyPrinter.scala
- Alphabetic
- By Inheritance
- PrettyPrinterBase
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
abstract
type
Doc <: DocOps
The representation type of pretty-printable documents.
-
trait
DocOps
extends AnyRef
The operations provided by a pretty-printable document that don't depend on the document's representation type.
-
type
Indent = Int
Indentation is expressed as integer space units.
-
type
Layout = String
The final layout of a document as a string.
-
trait
PrettyPrintable
extends AnyRef
Interface for pretty-printable values.
Interface for pretty-printable values. The default
toDocimplementation just uses thevaluecombinator on the receiver. -
type
Width = Int
Output medium width
Abstract Value Members
-
abstract
def
column(f: (Int) ⇒ Doc): Doc
Return the document produced by
fwhen it is passed the column at which rendering is currently placed. -
abstract
def
empty: Doc
An empty document.
An empty document. This is a left and right unit for the concatenation method. Called
nilin the paper. -
abstract
def
group(d: Doc): Doc
A document representing a choice among different ways to print a structure.
-
abstract
def
line(repl: Layout): Doc
A document representing a potential line break.
A document representing a potential line break. Behaves like the string
replif the break is omitted by a group. -
abstract
def
line: Doc
A document representing a potential line break.
A document representing a potential line break. Behaves like a space character if the break is omitted by a group.
-
abstract
def
linebreak: Doc
A document representing a potential line break.
A document representing a potential line break. Behaves like an empty string if the break is omitted by a group.
-
abstract
def
nest(d: Doc, j: Indent = defaultIndent): Doc
Nest a document by an indentation increment on top of the current nesting.
Nest a document by an indentation increment on top of the current nesting. In the paper version, the indentation parameter comes first, but we put it second here so that it can be given a default value.
-
abstract
def
nesting(f: (Int) ⇒ Doc): Doc
Return the document produced by
fwhen it is passed the nesting level (indentation) of the current line. -
abstract
def
pretty(d: Doc, w: Width = defaultWidth): Layout
Pretty print a document assuming a given output medium width.
Pretty print a document assuming a given output medium width. In the paper the width is the first parameter, but here we put it second so we can provide a default value.
-
implicit abstract
def
text(t: String): Doc
Convert a string to a document.
Convert a string to a document. The string should not contain any newline characters. Use
lineinstead.
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
align(d: Doc): Doc
Return a document that renders
dwith the nesting level set to the current indentation column. -
def
ampersand: Doc
An ampersand document.
-
def
angles(d: Doc): Doc
Return a document that encloses a given document between left and right angle brackets.
-
def
any(a: Any): Doc
Generic pretty-printer document for any type of value.
Generic pretty-printer document for any type of value. If
ais aVector,Map,ListorProduct, print it in a prefix list style, with the exception thatNilprints asNil. Tuples are pretty-printed using arrow notation. Strings are pretty-printed surrounded by double quotes. If none of these cases apply, use thetoDocmethod ona.nullprints asnull. -
implicit
def
anyToPrettyPrintable(a: Any): PrettyPrintable
Convert any value into a pretty-printable value.
Convert any value into a pretty-printable value. The value will be pretty-printed using the
valuecombinator. -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
asterisk: Doc
An asterisk document.
-
def
atsign: Doc
An at-sign document.
-
def
backquote: Doc
A backquote document.
-
def
backslash: Doc
A backslash document.
-
def
braces(d: Doc): Doc
Return a document that encloses a given document between left and right braces.
-
def
brackets(d: Doc): Doc
Return a document that encloses a given document between left and right square brackets.
-
def
caret: Doc
A caret document.
-
def
cat(ds: Seq[Doc]): Doc
Return a document that concatenates the documents in the given sequence either horizontally with
<>if they fit in the output medium width, or if not, vertically with<@@>. -
implicit
def
char(c: Char): Doc
Convert a character to a document.
Convert a character to a document. The character can be a newline.
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
colon: Doc
A colon document.
-
def
comma: Doc
A comma document.
-
val
defaultIndent: Int
Default indentation is four spaces.
-
val
defaultWidth: Int
Default layout width is 75 characters.
-
def
dollar: Doc
A dollar sign document.
-
def
dot: Doc
A dot (period) document.
-
def
dquote: Doc
A double quote document.
-
def
dquotes(d: Doc): Doc
Return a document that encloses a given document between double quotes.
-
def
enclose(l: Doc, d: Doc, r: Doc): Doc
Return a document that encloses a given document between left and right documents.
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equal: Doc
An equal sign document.
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
exclamation: Doc
An exclamation mark document.
-
def
fillcat(ds: Seq[Doc]): Doc
Return a document that concatenates the documents in the given sequence horizontally with
<>as long as they fit the output width, then inserts alinebreakand continues to the end of the sequence. -
def
fillsep(ds: Seq[Doc], sep: Doc): Doc
Return a document that concatenates the documents in the given sequence horizontally with
<+>as long as they fit the output width, then inserts alineand continues with the rest of the sequence.Return a document that concatenates the documents in the given sequence horizontally with
<+>as long as they fit the output width, then inserts alineand continues with the rest of the sequence. Separates documents with the given separator before the<+>. -
def
fillsep(ds: Seq[Doc]): Doc
Return a document that concatenates the documents in the given sequence horizontally with
<+>as long as they fit the output width, then inserts alineand continues with the rest of the sequence. -
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
folddoc(ds: Seq[Doc], f: (Doc, Doc) ⇒ Doc): Doc
Return a document that is the result of folding
fover the sequenceds.Return a document that is the result of folding
fover the sequenceds. Returns the empty document isdsis empty. -
def
forwslash: Doc
A forward slash document.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hang(d: Doc, i: Indent = defaultIndent): Doc
Return a document that is like
dbut whose second and subsequent lines have hanging indentation ofispaces (defaults to the deafult indentation).Return a document that is like
dbut whose second and subsequent lines have hanging indentation ofispaces (defaults to the deafult indentation). In other words, the first line is indented at the current nesting level and the remaining lines are indentedispaces more. -
def
hash: Doc
A hash mark document.
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
hcat(ds: Seq[Doc]): Doc
Return a document that concatenates the documents in the given sequence horizontally with
<>. -
def
hsep(ds: Seq[Doc], sep: Doc): Doc
Return a document that concatenates the documents in the given sequence horizontally with
<+>.Return a document that concatenates the documents in the given sequence horizontally with
<+>. Separates documents with the given separator before the<+>. -
def
hsep(ds: Seq[Doc]): Doc
Return a document that concatenates the documents in the given sequence horizontally with
<+>. -
def
indent(d: Doc, i: Indent = defaultIndent): Doc
Return a document that is
dbut with the first line indented byimore spaces. -
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
langle: Doc
A left angle bracket document.
-
def
lbrace: Doc
A left brace document.
-
def
lbracket: Doc
A left square bracket document.
-
def
list[T](l: Seq[T], prefix: String = "List", elemToDoc: (T) ⇒ Doc = (x : T) => value (x), sep: Doc = comma, sepfn: (Seq[Doc], Doc) ⇒ Doc = lsep): Doc
Return a document that pretty-prints a list in Scala notation, inserting line breaks between elements as necessary.
Return a document that pretty-prints a list in Scala notation, inserting line breaks between elements as necessary. The
prefixstring can be changed from the default"List". TheelemToDocargument can be used to alter the way each element is converted to a document (default: use thevaluecombinator).sepdefaults tocomma. -
def
lparen: Doc
A left parenthesis document.
-
def
lsep(ds: Seq[Doc], sep: Doc): Doc
Return a pretty-printer document for a separated sequence.
Return a pretty-printer document for a separated sequence.
sepis the separator. Line breaks are allowed before the sequence and after the separators between the elements of the sequence. The before line break turns into nothing if omitted. The internal line breaks turn intospaceif omitted. -
def
lsep2(ds: Seq[Doc], sep: Doc): Doc
Return a pretty-printer document for a separated sequence.
Return a pretty-printer document for a separated sequence.
sepis the separator. Line breaks are allowed before the separators between the elements of the sequence and at the end. Aspaceis inserted after each separator. The internal line breaks turn intospaceif omitted. The end line break turns into nothing if omitted. -
def
lterm(ds: Seq[Doc], term: Doc): Doc
Return a pretty-printer document for a sequence where each element is terminated by
term.Return a pretty-printer document for a sequence where each element is terminated by
term. Line breaks are allowed before the sequence and after the terminator between the elements of the sequence. The before line break turns into nothing if omitted. The internal line breaks turn intospaceif omitted. -
def
minus: Doc
An minus sign document.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
padto(p: Int, d: Doc): Doc
Return a document that pads
dout to a width ofp.Return a document that pads
dout to a width ofp. Ifdalready has a width greater than or equal tod, don't add any padding. This combinator is calledfillin the PPrint library. -
def
padtobreak(p: Int, d: Doc): Doc
As for
padtobut if the document width is already greater than or equal top, insert a possible line break and new nesting level instead of not adding any padding.As for
padtobut if the document width is already greater than or equal top, insert a possible line break and new nesting level instead of not adding any padding. This combinator is calledfillBreakin the PPrint library. -
def
parens(d: Doc): Doc
Return a document that encloses a given document between left and right parentheses.
-
def
percent: Doc
A percent sign document.
-
def
plist(l: List[PrettyPrintable], prefix: String = "List", elemToDoc: (PrettyPrintable) ⇒ Doc = _.toDoc, sep: Doc = comma, sepfn: (Seq[Doc], Doc) ⇒ Doc = lsep): Doc
Return a document that pretty-prints a list of pretty-printables in Scala notation, inserting line breaks between elements as necessary.
Return a document that pretty-prints a list of pretty-printables in Scala notation, inserting line breaks between elements as necessary. The
prefixstring can be changed from the default"List". TheelemToDocargument can be used to alter the way each element is converted to a document (default: call the element'stoDocmethod).sepdefaults to acomma. -
def
plus: Doc
An plus sign document.
-
def
pretty(p: PrettyPrintable): Layout
Pretty-print a pretty-printable value.
Pretty-print a pretty-printable value. If the value passed is not a pretty-printable document, it will be converted to one using the implicit conversion
anyToPrettyPrintable. -
def
pretty_any(a: Any): Layout
Pretty-print any value using the
anymethod. -
def
pseq(l: Seq[PrettyPrintable], prefix: String = "Seq", elemToDoc: (PrettyPrintable) ⇒ Doc = _.toDoc, sep: Doc = comma, sepfn: (Seq[Doc], Doc) ⇒ Doc = lsep): Doc
Return a document that pretty-prints a sequence of pretty-printables in Scala notation, inserting line breaks between elements as necessary.
Return a document that pretty-prints a sequence of pretty-printables in Scala notation, inserting line breaks between elements as necessary. The
prefixstring can be changed from the default"Seq". TheelemToDocargument can be used to alter the way each element is converted to a document (default: call the element'stoDocmethod).sepdefaults to acomma. -
def
question: Doc
A question mark document.
-
def
rangle: Doc
A right angle bracket document.
-
def
rbrace: Doc
A right brace document.
-
def
rbracket: Doc
A right square bracket document.
-
def
rparen: Doc
A right parenthesis document.
-
def
semi: Doc
A semicolon document.
-
def
sep(ds: Seq[Doc]): Doc
Return a document that concatenates the documents in the given sequence either horizontally with
<+>if they fit in the output medium width, or if not, vertically with<@>. -
def
seq[T](l: Seq[T], prefix: String = "Seq", elemToDoc: (T) ⇒ Doc = (x : T) => value (x), sep: Doc = comma, sepfn: (Seq[Doc], Doc) ⇒ Doc = lsep): Doc
Return a document that pretty-prints a sequence in Scala notation, inserting line breaks between elements as necessary.
Return a document that pretty-prints a sequence in Scala notation, inserting line breaks between elements as necessary. The
prefixstring can be changed from the default"Seq". TheelemToDocargument can be used to alter the way each element is converted to a document (default: use thevaluecombinator).sepdefaults tocomma. -
def
softbreak: Doc
Return a document that behaves like
emptyif the resulting output fits the page, otherwise it behaves likeline. -
def
softline: Doc
Return a document that behaves like
spaceif the resulting output fits the page, otherwise it behaves likeline. -
def
space: Doc
A space document.
-
def
spaces(n: Int): Doc
Return a document representing
nspaces ifns greater than zero, otherwise return an empty document. -
def
squote: Doc
A single quote document.
-
def
squotes(d: Doc): Doc
Return a document that encloses a given document between single quotes.
-
def
ssep(ds: Seq[Doc], sep: Doc): Doc
Return a document that concatenates the documents in the given sequence and separates adjacent documents with
sepwith no space around the separator. -
def
sterm(ds: Seq[Doc], term: Doc): Doc
Return a document that concatenates the documents in the given sequence and terminates each document with
term. -
def
string(s: String): Doc
Convert a string to a document.
Convert a string to a document. The string is allowed to contain newline characters. If no newlines are included, it is best to use
textdirectly instead. -
def
surround(d: Doc, b: Doc): Doc
Return a document that encloses a given document
dbetween two occurrences of another documentb. -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
tilde: Doc
A tilde document.
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
underscore: Doc
An underscore document.
-
def
value(v: Any): Doc
Return a document representing a value formatted using
toStringand thestringcombinator.Return a document representing a value formatted using
toStringand thestringcombinator. As a special case, if the value is a null reference it is formatted asnull. -
def
vcat(ds: Seq[Doc]): Doc
Return a document that concatenates the documents in the given sequence vertically with
<@@>. -
def
verticalbar: Doc
A vertical bar document.
-
def
vsep(ds: Seq[Doc], sep: Doc): Doc
Return a document that concatenates the documents in the given sequence vertically with
<@>.Return a document that concatenates the documents in the given sequence vertically with
<@>. Separates documents with the given separator before the<@>. -
def
vsep(ds: Seq[Doc]): Doc
Return a document that concatenates the documents in the given sequence vertically with
<@>. -
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
width(d: Doc, f: (Int) ⇒ Doc): Doc
Return a document that renders
dbeside the document obtained by runningfon the width ofd.