Class/Object

org.typelevel.paiges

Doc

Related Docs: object Doc | package paiges

Permalink

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
Visibility
  1. Public
  2. All

Abstract Value Members

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

    Permalink
    Definition Classes
    Equals
  2. abstract def productArity: Int

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

    Permalink
    Definition Classes
    Product

Concrete Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink

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

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

    Permalink

    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.

  5. def *(n: Int): Doc

    Permalink

    Synonym for .repeat.

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

  6. def +(that: Doc): Doc

    Permalink

    Append the given Doc to this one.

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

    Permalink

    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.

  8. def /(that: Doc): Doc

    Permalink

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

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

    Permalink

    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.

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

    Permalink

    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).

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

    Permalink

    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).

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

    Permalink

    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).

  13. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  14. def aligned: Doc

    Permalink

    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

  15. final def asInstanceOf[T0]: T0

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

    Permalink

    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.

  17. def clone(): AnyRef

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

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

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

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

    Permalink

    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.

  22. def flattenOption: Option[Doc]

    Permalink

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

    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.

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

    Permalink
    Definition Classes
    AnyRef → Any
  24. def grouped: Doc

    Permalink

    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.

  25. lazy val hashCode: Int

    Permalink

    Compute a hash code for this Doc.

    Compute a hash code for this Doc.

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

    Permalink

    Returns true if all renders return the empty string

  27. final def isInstanceOf[T0]: Boolean

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

    Permalink

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

  29. def line(that: Doc): Doc

    Permalink

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

  30. def lineOrSpace(that: String): Doc

    Permalink

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

  31. def lineOrSpace(that: Doc): Doc

    Permalink

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

  32. def maxWidth: Int

    Permalink

    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.

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

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

    Permalink

    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).

  35. def nonEmpty: Boolean

    Permalink

    d.nonEmpty == !d.isEmpty

  36. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  37. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  38. def productIterator: Iterator[Any]

    Permalink
    Definition Classes
    Product
  39. def productPrefix: String

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

    Permalink

    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.

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

    Permalink

    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).

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

    Permalink

    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.

  43. def renderTrim(width: Int): String

    Permalink

    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.

  44. def renderWideStream: Stream[String]

    Permalink

    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.

  45. def repeat(count: Int): Doc

    Permalink

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

  46. def representation(forceLazy: Boolean = false): Doc

    Permalink

    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 forceLazy = true is passed, then any LazyDoc nodes are evaluated (making this potentially-expensive method even more expensive).

  47. def space(that: String): Doc

    Permalink

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

  48. def space(that: Doc): Doc

    Permalink

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

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

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

    Permalink

    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.

  51. def toString(): String

    Permalink

    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
  52. final def wait(): Unit

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

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

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

    Permalink

    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.

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

    Permalink

    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