06 Formatting
Converting a DUST document to DUST writes its canonical spelling: the same value
always formats to the same bytes. For example, stardust convert input.dust
output.dust writes canonical DUST to output.dust. stardust fmt keeps map
keys in source order, so its output is canonical only when the keys are sorted. Canonical output is what stardust prints,
and what hash digests, so two
programs that format alike are the same program.
The rules are those of RON and DUST. In brief, the formatter:
- sorts map keys and collects boolean members into a tag group;
- uses the short forms
name,:name,(f x),`x, and\xfor locals, constants, invocations, quotes, and muted forms; - drops the brackets of a root list with two or more forms, writing one form per line;
- normalizes
#utcand#durpayloads, so#dur PT90Mbecomes#dur PT1H30M.