From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 97AC5BC57 for ; Thu, 15 Apr 2010 07:42:42 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqYBAENExktCbwQakWdsb2JhbACDE5hOFQEBAQEJCwoHEQQerGuRNgWBLIJ0boMt X-IronPort-AV: E=Sophos;i="4.52,210,1270418400"; d="scan'208";a="57074031" Received: from out2.smtp.messagingengine.com ([66.111.4.26]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 15 Apr 2010 07:42:42 +0200 Received: from compute2.internal (compute2.internal [10.202.2.42]) by gateway1.messagingengine.com (Postfix) with ESMTP id 1F9A3EADB5; Thu, 15 Apr 2010 01:42:41 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute2.internal (MEProxy); Thu, 15 Apr 2010 01:42:41 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=message-id:date:from:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; s=smtpout; bh=NuHy5hrnKPlrX6BPunpD7yThbC0=; b=HSDmS320zRtAipb2RwdmQgYf0Lp58A8EsSHy/7CIMTJwPDHEVpmgvMw8lzMHGqSQf8dNy8S4JzNh3/TfXPvc4D/XlEcIQXjChLRjlXVgjqt+8GxCXIg4eOYWMizb9bosg2yggsau84SKM7aZ5RE3vOyZkCcI0gXm09W5DLHxVgg= X-Sasl-enc: imtAz/vLNeabfFHIS+noqB39GMcvuIMBuI8B86PTu606 1271310160 Received: from [192.168.2.4] (c-98-248-33-155.hsd1.ca.comcast.net [98.248.33.155]) by mail.messagingengine.com (Postfix) with ESMTPSA id 95C694C1884; Thu, 15 Apr 2010 01:42:40 -0400 (EDT) Message-ID: <4BC6A74F.7010106@ens-lyon.org> Date: Wed, 14 Apr 2010 22:42:39 -0700 From: Martin Jambon User-Agent: Thunderbird 2.0.0.22 (X11/20090908) MIME-Version: 1.0 To: Kaustuv Chaudhuri Cc: caml-list Subject: Re: [Caml-list] Inspect and dump values on the OCaml heap References: <3FB04EDC-37F4-4336-A435-13ACF038051D@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ens-lyon:01 ocaml:01 ocaml:01 renders:01 graphviz:01 nodes:01 lix:01 invariants:01 invariants:01 printexc:01 foo:01 foo:01 printexc:01 wrote:01 wrote:01 Kaustuv Chaudhuri wrote: > On Wed, Apr 14, 2010 at 5:02 PM, Kaspar Rohrer wrote: >> [...] > > Implementing dumpers seems like a teething procedure for > OCaml hackers. Here's my own attempt from a couple of years ago. > It handles cycles, renders SVGs (via Graphviz), and can accept > data structure "descriptions" to produce better names for the > internal nodes. It is almost 100% OCaml. > > http://www.lix.polytechnique.fr/~kaustuv/misc/ocaml_show.html > > I am convinced that such things have *no* usefulness. If you > are trying to debug your data structure, state its global > invariants, prove (at whatever level of formality you are most > comfortable with) that all API functions preserve the invariants, > and use the module system to hide functions that do not > preserve them. You will be done faster than trying to make > sense of graphs and your code will be better. The only reason why I wrote Dum was to print exceptions deeper than Printexc.to_string: # exception Foo of [`Bar of string];; exception Foo of [ `Bar of string ] # Printexc.to_string (Foo (`Bar "abc"));; - : string = "Foo(_)" # Dum.to_string (Foo (`Bar "abc"));; - : string = "((\"Foo\") (3303859 \"abc\"))" Martin -- http://mjambon.com/