org.typelevel.paiges

Doc

sealed abstract class Doc extends Product with Serializable

implementation of Wadler's classic "A Prettier Printer"

http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Doc
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Doc()

Abstract Value Members

  1. abstract def canEqual(that: Any): Boolean

    Definition Classes
    Equals
  2. abstract def productArity: Int

    Definition Classes
    Product
  3. abstract def productElement(n: Int): Any

    Definition Classes
    Product

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def &(that: Doc): Doc

    Append the given Doc to this one, separated by a space.

  5. def &:(that: String): Doc

    Append the given String to this Doc, separated by a space.

    Append the given String to this Doc, separated by a space.

    The expression str &: d is equivalent to Doc.text(str) & d.

  6. def *(n: Int): Doc

    Synonym for .

    Synonym for .repeat. If n > 0 repeat the doc n times, else return empty

  7. def +(that: Doc): Doc

    Append the given Doc to this one.

  8. def +:(str: String): Doc

    Prepend the given String to this Doc.

    Prepend the given String to this Doc.

    The expression str +: d is equivalent to Doc.text(str) + d.

  9. def /(that: Doc): Doc

    Append the given Doc to this one, separated by a newline.

  10. def /:(str: String): Doc

    Prepend the given String to this Doc, separated by a newline.

    Prepend the given String to this Doc, separated by a newline.

    The expression str /: d is equivalent to Doc.text(str) / d.

  11. def :&(that: String): Doc

    Append the given String to this Doc, separated by a space.

    Append the given String to this Doc, separated by a space.

    The expression d :& str is equivalent to d & Doc.text(str).

  12. def :+(str: String): Doc

    Append the given String to this Doc.

    Append the given String to this Doc.

    The expression d :+ str is equivalent to d + Doc.text(str).

  13. def :/(str: String): Doc

    Append the given String to this Doc, separated by a newline.

    Append the given String to this Doc, separated by a newline.

    The expression d :/ str is equivalent to d / Doc.text(str).

  14. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  15. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  16. def aligned: Doc

    aligned sets the nesting to the column position before we render the current doc.

    aligned sets the nesting to the column position before we render the current doc. This is useful if you have:

    Doc.text("foo") + (Doc.text("bar").line(Doc.text("baz"))).align

    which will render as:

    foobar baz

  17. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  18. def bracketBy(left: Doc, right: Doc, indent: Int = 2): Doc

    Bookend this Doc between the given Docs.

    Bookend this Doc between the given Docs.

    If the documents (when flattened) all fit on one line, then newlines will be collapsed, spaces will be added, and the document will render on one line. If you do not want a space, see tightBracketBy

    Otherwise, newlines will be used on either side of this document, and the requested level of indentation will be added as well.

  19. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  21. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  22. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  23. def flatten: Doc

    Convert this Doc to a single-line representation.

    Convert this Doc to a single-line representation.

    All newlines are replaced with spaces (and optional indentation is ignored). The resulting Doc will never render any newlines, no matter what width is used.

  24. def flattenOption: Option[Doc]

    This method is similar to flatten, but returns None if no flattening was needed (i.

    This method is similar to flatten, but returns None if no flattening was needed (i.e. if no newlines or unions were present).

    As with flatten, the resulting Doc (if any) will never render any newlines, no matter what width is used.

  25. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  26. def grouped: Doc

    Treat this Doc as a group that can be compressed.

    Treat this Doc as a group that can be compressed.

    The effect of this is to replace newlines with spaces, if there is enough room. Otherwise, the Doc will be rendered as-is.

  27. lazy val hashCode: Int

    Compute a hash code for this Doc.

    Compute a hash code for this Doc.

    Definition Classes
    Doc → AnyRef → Any
  28. def isEmpty: Boolean

    Returns true if all renders return the empty string

  29. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  30. def line(str: String): Doc

    Append the given String to this one, separated by a newline.

  31. def line(that: Doc): Doc

    Append the given Doc to this one, separated by a newline.

  32. def lineOrSpace(that: String): Doc

    Append the given String to this Doc, using a space (if there is enough room), or a newline otherwise.

  33. def lineOrSpace(that: Doc): Doc

    Append the given Doc to this one, using a space (if there is enough room), or a newline otherwise.

  34. def maxWidth: Int

    Returns the largest width which may affect how this Doc renders.

    Returns the largest width which may affect how this Doc renders. All widths larger than this amount are guaranteed to render the same.

    Note that this does not guarantee that all widths below this value are distinct, just that they may be distinct. This value is an upper-bound on widths that produce distinct renderings, but not a least upper-bound.

  35. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  36. def nested(amount: Int): Doc

    Nest appends spaces to any newlines occurring within this Doc.

    Nest appends spaces to any newlines occurring within this Doc.

    The effect of this is cumulative. For example, the expression x.nested(1).nested(2) is equivalent to x.nested(3).

  37. def nonEmpty: Boolean

    d.

    d.nonEmpty == !d.isEmpty

  38. final def notify(): Unit

    Definition Classes
    AnyRef
  39. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  40. def productIterator: Iterator[Any]

    Definition Classes
    Product
  41. def productPrefix: String

    Definition Classes
    Product
  42. def render(width: Int): String

    Render this Doc as a String, limiting line lengths to width or shorter when possible.

    Render this Doc as a String, limiting line lengths to width or shorter when possible.

    Note that this method does not guarantee there are no lines longer than width -- it just attempts to keep lines within this length when possible.

  43. def renderStream(width: Int): Stream[String]

    Render this Doc as a stream of strings, treating width in the same way as render does.

    Render this Doc as a stream of strings, treating width in the same way as render does.

    The expression d.renderStream(w).mkString is equivalent to d.render(w).

  44. def renderStreamTrim(width: Int): Stream[String]

    Render this Doc as a stream of strings, treating width in the same way as render does.

    Render this Doc as a stream of strings, treating width in the same way as render does.

    The expression d.renderStream(w).mkString is equivalent to d.render(w).

    Lines consisting of only indentation are represented by the empty string.

  45. def renderTrim(width: Int): String

    Render this Doc as a String, limiting line lengths to width or shorter when possible.

    Render this Doc as a String, limiting line lengths to width or shorter when possible.

    Note that this method does not guarantee there are no lines longer than width -- it just attempts to keep lines within this length when possible.

    Lines consisting of only indentation are represented by the empty string.

  46. def renderWideStream: Stream[String]

    Render this Doc as a stream of strings, using the widest possible variant.

    Render this Doc as a stream of strings, using the widest possible variant. This is the same as render(Int.MaxValue) except it is more efficient.

  47. def repeat(count: Int): Doc

    If n > 0, repeat the Doc that many times, else return empty

  48. def representation(forceUnions: Boolean = false): Doc

    Produce a verbose string representation of this Doc.

    Produce a verbose string representation of this Doc.

    Unlike render, this method will reveal the internal tree structure of the Doc (i.e. how concatenation and union nodes are constructed), as well as the contents of every text node.

    By default, only the left side of union nodes is displayed. If forceUnions = true is passed, then both sides of the union are rendered (making this potentially-expensive method even more expensive).

  49. def space(that: String): Doc

    Append the given String to this Doc, separated by a space.

  50. def space(that: Doc): Doc

    Append the given Doc to this one, separated by a space.

  51. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  52. def tightBracketBy(left: Doc, right: Doc, indent: Int = 2): Doc

    Bookend this Doc between the given Docs.

    Bookend this Doc between the given Docs.

    If the documents (when flattened) all fit on one line, then newlines will be collapsed, without a space and the document will render on one line. If you want the newline to collapse to a space, see bracketBy.

    Otherwise, newlines will be used on either side of this document, and the requested level of indentation will be added as well.

  53. def toString(): String

    Return a very terse string for this Doc.

    Return a very terse string for this Doc.

    To get a full representation of the document's internal structure, see verboseString.

    Definition Classes
    Doc → AnyRef → Any
  54. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  55. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  56. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  57. def writeTo(width: Int, pw: PrintWriter): Unit

    Render this Doc at the given width, and write it to the given PrintWriter.

    Render this Doc at the given width, and write it to the given PrintWriter.

    The expression x.writeTo(w, pw) is equivalent to pw.print(x.render(w)), but will usually be much more efficient.

    This method does not close pw or have any side-effects other than the actual writing.

  58. def writeToTrim(width: Int, pw: PrintWriter): Unit

    Render this Doc at the given width, and write it to the given PrintWriter.

    Render this Doc at the given width, and write it to the given PrintWriter.

    The expression x.writeTo(w, pw) is equivalent to pw.print(x.render(w)), but will usually be much more efficient.

    This method does not close pw or have any side-effects other than the actual writing.

    Lines consisting only of indentation are represented by the empty string.

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped