From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id pB97MEx1031223 for ; Fri, 9 Dec 2011 08:22:14 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjIFAJ+14U7VuiYS/2dsb2JhbABDhDZQpWuBBYFyAQEEAQwXVgULCQIaAiYCAiwrBi6HbAIGpW+RIxSBIIhzgRYEpxI X-IronPort-AV: E=Sophos;i="4.71,325,1320620400"; d="scan'208";a="134664907" Received: from solaria.dimino.org ([213.186.38.18]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 09 Dec 2011 08:22:08 +0100 Received: from aurora (localhost.localdomain [127.0.0.1]) by solaria.dimino.org (Postfix) with ESMTP id 3B8F680088; Fri, 9 Dec 2011 08:22:08 +0100 (CET) Received: by aurora (Postfix, from userid 1000) id D64BE41315; Fri, 9 Dec 2011 08:22:12 +0100 (CET) Message-ID: <1323415332.3523.34.camel@aurora> From: =?ISO-8859-1?Q?J=E9r=E9mie?= Dimino To: Gabriel Scherer Cc: Martin Jambon , caml-list@inria.fr Date: Fri, 09 Dec 2011 08:22:12 +0100 In-Reply-To: References: <1323271707.32238.17.camel@arrakis> <4EDF9AAE.5050604@crans.org> <1323279292.32238.48.camel@arrakis> <4EE0A6C6.8040703@lri.fr> <4EE0FFDE.1050107@ens-lyon.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.0.3-3 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id pB97MEx1031223 Subject: Re: [Caml-list] Generic printer patch Le jeudi 08 décembre 2011 à 22:39 +0100, Gabriel Scherer a écrit : > Of course, the "right" way to print/marshal data without changing the > language is to build a printer for your type from printer combinators. > Such combinators are available for example: > - in Jane Street Core library ( a Sexpable interface in each datatype module ) > - in Xavier Clerc's Kaputt testing framework : > http://kaputt.x9c.fr/distrib/api/Utils.html > > You can also use metaprogramming (.. camlp4) to generate printer > functions from datatypes description automatically, using such > combinators. See: > - Markus Mottl's 'type-conv': http://hg.ocaml.info/release/type-conv > - Jeremy Yallop's 'deriving': http://code.google.com/p/deriving/ These solutions would be usable only if everybody were using it. Right now almost nobody use them, and so if you want to print types coming from external library you still have to write the printer yourself. > Of course, printing values magically is still easier: you don't have > to build the printer yourself, passing subtype printers when > necessary, etc. I think Std.dump is reasonable for quick hacks or > debugging usage. If think my hack is reasonable too, you just have to replace ocamlc and ocamlopt (if you already use ocaml 3.12.1) by the new compilers and it will work. Of course don't use it in production code ;-) Cheers, -- Jérémie