factoring out common pretty printers for AST and Typed