I found https://github.com/janestreet/custom_printf quite straightforward to understand and easy to use, if most of your types already have sexp converters and to_string functions.


On Tue, Jul 1, 2014 at 5:59 AM, Gabriel Kerneis <gabriel@kerneis.info> wrote:
Dear all,

in CIL <http://cil.sf.net>, 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?

Many thanks for any example you could provide.

With best regards,
--
Gabriel

--
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs