On Tue, Jul 1, 2014 at 10:59 AM, Gabriel Kerneis wrote: > Dear all, > > in CIL , the module Pretty provides a Format-like > interface with a few extensions compared to usual format strings. > Implementation-wise, it uses string_of_format and re-implements most of > the logic of the pre-4.02 Format module, with Obj.magic all over the > place. > > I wondered if anyone has done something similar in their own project > (extending Format in one way or another), and if the new GADT-based > approach could provide a cleaner solution? > > One thing I quite like with the current code, despite its uglyness, is > its concision. I am right in assuming that switching to GADTs would > require a lot more boilerplate? > I had a quick look at [Pretty.dprintf] and I think you could use [CamlinternalFormat.make_printf] to implement it with 4.02. @-sequences are already recognized by the format parser in the compiler, but it should be compatible with [Pretty]'s syntax, you just have to interpret the constructors differently. It should actually make the code of [Pretty.dprintf] much simpler. -- Jeremie