Doc = t match { case Num (d) => value (d) case Var (s) => s case Neg (e) => parens ("-" <> show (e)) case Add (l, r) => showbin (l, "+", r) case Sub (l, r) => showbin (l, "-", r) case Mul (l, r) => showbin (l, "*", r) case Div (l, r) => showbin (l, "/", r) case Null () => semi case Seqn (ss) => group (braces (nest (line <> ssep (ss map show, line)) <> line)) case Asgn (v, e) => show (v) <+> "=" <+> show (e) <> semi case While (e, b) => "while" <+> parens (show (e)) <> group (nest (line <> show (b))) } def showbin (l : ImperativeNode, op : String, r : ImperativeNode) : Doc = parens (show (l) <+> op <+> show (r))