1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162(* CR-someday diml: we should define a GADT for this:
{[
type 'a t =
| Int : int t
| Box : ...
| Colored : ...
]}
This way we could separate the creation of messages from the
actual rendering.
*)type'at=Format.formatter->'a->unitletkstrfffmt=letbuf=Buffer.create17inletffmt=Format.pp_print_flushfmt();f(Buffer.contentsbuf)inFormat.kfprintff(Format.formatter_of_bufferbuf)fmtletfailwithfmt=kstrffailwithfmtletlist=Format.pp_print_listletstringsppf=Format.pp_print_stringppfslettext=Format.pp_print_textletnl=Format.pp_print_newlineletbreakfmt()=Format.fprintffmt"@,"letprefixfgppfx=fppf;gppfxletocaml_listppfmt=function|[]->Format.pp_print_stringfmt"[]"|l->Format.fprintffmt"@[<hv>[ %a@ ]@]"(list~pp_sep:(funfmt()->Format.fprintffmt"@,; ")pp)lletquotedfmt=Format.fprintffmt"%S"letconst:'at->'a->unitt=funppa'fmt()->ppfmta'letrecordfmt=function|[]->Format.pp_print_stringfmt"{}"|xs->letppfmt(field,pp)=Format.fprintffmt"@[<hov 1>%s@ =@ %a@]"fieldpp()inletpp_sepfmt()=Format.fprintffmt"@,; "inFormat.fprintffmt"@[<hv>{ %a@ }@]"(Format.pp_print_list~pp_seppp)xslettupleppfappfbfmt(a,b)=Format.fprintffmt"@[<hv>(%a, %a)@]"ppfaappfbbletoptionalppffmt=function|None->Format.fprintffmt"<None>"|Somea->ppffmta