Module Ext_pp

type t;

A simple pretty printer

Advantage compared with Format, P.newline does not screw the layout, have better control when do a newline (sicne JS has ASI) Easy to tweak

  • be a little smarter
  • buffer the last line, so that we can do a smart newline, when it's really safe to do so
let indent_length: int;
let string: t => string => unit;
let space: t => unit;
let nspace: t => int => unit;
let group: t => int => (unit => 'a) => 'a;

group will record current indentation and indent futher

let vgroup: t => int => (unit => 'a) => 'a;
let paren: t => (unit => 'a) => 'a;
let brace: t => (unit => 'a) => 'a;
let paren_group: t => int => (unit => 'a) => 'a;
let cond_paren_group: t => bool => int => (unit => 'a) => 'a;
let paren_vgroup: t => int => (unit => 'a) => 'a;
let brace_group: t => int => (unit => 'a) => 'a;
let brace_vgroup: t => int => (unit => 'a) => 'a;
let bracket_group: t => int => (unit => 'a) => 'a;
let bracket_vgroup: t => int => (unit => 'a) => 'a;
let newline: t => unit;
let at_least_two_lines: t => unit;
let from_channel: Stdlib.out_channel => t;
let from_buffer: Stdlib.Buffer.t => t;
let flush: t => unit => unit;
let current_line: t => int;
let current_column: t => int;