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 pB7GuLOd006386 for ; Wed, 7 Dec 2011 17:56:21 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgQBAG6Z307ZRrfDmWdsb2JhbABDhDZQoxmCNSIBAQEBAQgLCwcUJYFyAQEFDBcEEUARCQIaAgUWCwICCQMCAQIBRRMIAogFpTCRV4E0hmiCAoEWBJRrhUqMWg X-IronPort-AV: E=Sophos;i="4.71,314,1320620400"; d="scan'208";a="134395820" Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by mail1-smtp-roc.national.inria.fr with ESMTP; 07 Dec 2011 17:56:16 +0100 X-Originating-IP: 217.70.178.130 Received: from mfilter1-d.gandi.net (mfilter1-d.gandi.net [217.70.178.130]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id 1014DA8096 for ; Wed, 7 Dec 2011 17:56:16 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter1-d.gandi.net Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by mfilter1-d.gandi.net (mfilter1-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id Mb4GithKyWXp for ; Wed, 7 Dec 2011 17:56:14 +0100 (CET) X-Originating-IP: 129.175.29.25 Received: from [129.175.29.25] (lri29-25.lri.fr [129.175.29.25]) (Authenticated sender: francois.bobot@bobot.eu) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 9E8CDA809D for ; Wed, 7 Dec 2011 17:56:14 +0100 (CET) Message-ID: <4EDF9AAE.5050604@crans.org> Date: Wed, 07 Dec 2011 17:56:14 +0100 From: =?UTF-8?B?RnJhbsOnb2lzIEJvYm90?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111114 Icedove/3.1.16 MIME-Version: 1.0 To: caml-list@inria.fr References: <1323271707.32238.17.camel@arrakis> In-Reply-To: <1323271707.32238.17.camel@arrakis> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id pB7GuLOd006386 X-Validation-by: bobot@lri.fr Subject: Re: [Caml-list] Generic printer patch Le 07/12/2011 16:28, Jérémie Dimino a écrit : > Hi, > > I have made a patch for ocaml 3.12.1 which allow to have a generic > printing function. The patch is available here: > [...] > Of course it is limited to what the compiler knows, for example the > following function will always returns "[;]": > > let f x = show [x; x] > > But i think it is already very useful for debugging. Great job in so few time. That's right that can be an awesome feature. I haven't tested it yet. I just read the diff. But I have some questions : 1) If I understand well the "%show" command is expanded into the ocaml code (lambda-code) which can print the type. So, for instance, in the case of a list, your code generates a recursive function "aux" and it applies this new "aux" function to the argument of "%show". Do you plan to add in the module List a function : val string_of_list : ('a -> string) -> 'a list -> string and to generate only the call to this function instead of generating the "aux" function every time? Or do you do it purposely? 2) Could you imagine to generalize it to Format.formatter or to out_channel (without creating a string and concatenating)? Romain Bardou add in the mantis tracker (I can't give you the bugtracking number since mantis "is currently offline for maintenance") a feature wish for a new conversion specification that can print anything. Do you think you can fulfill is dream? 3) Is it impossible to reuse/merge with the code of the top level that print ocaml values? Thank you for providing this code. Funny the way you find the user defined function. Be careful to not implement type classes in Ocaml ;) -- François Bobot