123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960(* 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_newlineletprefixfgppfx=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