Atomo provides a handy wrapper for the Haskell
Text.PrettyPrint system. The documentation here is largely based off of its own.
Turn an object into a pretty-printed document, which can be used in other pretty-printers. This is defined on
Object, so everything has it, but you should override this if possible.
Pretty-printing a value should yield something that looks like the expression that created that value. If it cannot be pretty-printed cleanly, make it obvious, usually via surrounding some description with angle brackets (
Documents From Values
A document of height and width 1, containing a literal character.
A document of height 1 containing a literal string.
Satisfies the following laws:
text: s <> text: t == text: (s .. t) text: "" <> x == x, if x is non-empty
The side condition on the last law is necessary because text "" has height 1, while empty has no height.
Pretty zero-width-text: s → Pretty | s is-a?: String
Some text, but without any width. Use for non-printing text such as a HTML or Latex tags.
(Just a blank line.)
b, except that if the last line of the first argument stops at least one position before the first line of the second begins, these two lines are overlapped.
(x \\ y) <> z == x $$ (y <> z), if y is non-empty
Nest (or indent) a document by a given number of positions (which may also be negative).
nest: satisfies the laws:
x nest: 0 == x (x nest: a) nest: b == x nest: (a + b) (x <> y) nest: a == x nest: a <> y nest: a (x \\ y) nest: a == x nest: a \\ y nest: a Pretty empty nest: a == Pretty empty x <> y nest: a = x <> y, if x is non-empty