Canonical

Canonical :: # (opaque)
print : Document -> Str

Print a Document in the one spelling the KDL test suite records: props sorted and deduped, four spaces per depth, #true/#false/#null, an exponent's sign always written, and a trailing newline. Cannot fail.

An empty Document prints as a single newline: "a newline after the last node" holds even when there is no last node.

print_pretty : Document, Indent -> Str

Every rule print follows, with two changes: a Text Body holding a newline is written as a multi-line string rather than escaped onto one line, and one level of depth is the Indent the caller asks for. A Node name, a Prop key and an Annotation are spelled as print spells them.

Indent : [Spaces(U64), Tabs(U64)]

One level of indentation, as a count of one character. A caller cannot spell anything but whitespace, so a printed Document cannot stop being one.