compiler: Add a write method.

Not used by the compiler, don't worry.
Add an initial stab at a non-pretty printer.
formatter: Clean up a few of the more egregious problems.