caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: "Jérémie Dimino" <jeremie@dimino.org>, "caml users" <caml-list@inria.fr>
Subject: Re: [Caml-list] Generic printer patch
Date: Fri, 9 Dec 2011 10:26:06 +0100	[thread overview]
Message-ID: <CAPFanBF6guT0Lg4xxmxJ3HKA+Zd5aW5f0RxLrNGLdYtNpOmF6A@mail.gmail.com> (raw)
In-Reply-To: <1323415332.3523.34.camel@aurora>

> 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.

Indeed. It's just that in some cases (eg. you are no expert user
and/or use the ocaml binary packages of your distribution) the cost of
patching the compiler is quite high, and Std.dump is useful a degraded
but work-out-of-the-box solution.

On Fri, Dec 9, 2011 at 8:22 AM, Jérémie Dimino <jeremie@dimino.org> wrote:
> 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
>


  reply	other threads:[~2011-12-09  9:26 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-07 15:28 Jérémie Dimino
2011-12-07 16:46 ` Alex Rubinsteyn
2011-12-07 17:10   ` Jérémie Dimino
2011-12-07 16:56 ` François Bobot
2011-12-07 17:34   ` Jérémie Dimino
2011-12-08 12:00     ` Romain Bardou
2011-12-08 14:21       ` Gerd Stolpmann
2011-12-08 18:20       ` Martin Jambon
2011-12-08 21:39         ` Gabriel Scherer
2011-12-09  7:22           ` Jérémie Dimino
2011-12-09  9:26             ` Gabriel Scherer [this message]
2011-12-09  7:15         ` Jérémie Dimino
2011-12-08  2:33 ` Edgar Friendly
2011-12-08  7:28   ` François Bobot
2011-12-08  9:00   ` Alain Frisch
2011-12-08  9:24     ` Gerd Stolpmann
2011-12-08 10:32       ` Alain Frisch
2011-12-08 10:41         ` Jonathan Protzenko
2011-12-08 12:00           ` Philippe Veber
2011-12-08  5:26 ` Martin Jambon
2011-12-08  6:52   ` Jérémie Dimino
2011-12-08  7:44     ` Martin Jambon
2011-12-08  9:37       ` Jérémie Dimino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPFanBF6guT0Lg4xxmxJ3HKA+Zd5aW5f0RxLrNGLdYtNpOmF6A@mail.gmail.com \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=jeremie@dimino.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).