Formatter.Render

Render a Logical Printing Tree to its final formatted source string.

renderRoot walks the RootBox's top-level children, renders each one through the Box renderer (Formatter.Render.MakeRenderBox), and joins the results with newlines. Box is the only backend: every construct goes through Formatter.Render.Box's Line/Box IR, and one the renderer does not handle is an Err that fails the format rather than falling back to anything.

lptToBoxJson : LPNode -> Result String String

Serialise the Box each top-level child renders to as a JSON array (one entry per declaration), for the --box debug flag — the Box analogue of the --lpt LPT dump. An Err from any child (an unhandled construct) aborts.

renderRoot : LPNode -> Result String String

Render every top-level child of the RootBox and join them with newlines.

renderRootChildren : LPNode -> Result String (Array String)

The same render, one string per top-level child instead of one string for the file.

renderRoot is these joined with newlines. They are needed apart by Formatter.Audit.DecisionTrace, which has to say which declaration's output moved between two formats: a decision that flipped inside a declaration whose output is unchanged caused nothing, and reporting it beside the ones that did would bury them.