Browse thread
Inspect and dump values on the OCaml heap
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2010-04-15 (05:42) |
From: | Martin Jambon <martin.jambon@e...> |
Subject: | Re: [Caml-list] Inspect and dump values on the OCaml heap |
Kaustuv Chaudhuri wrote: > On Wed, Apr 14, 2010 at 5:02 PM, Kaspar Rohrer <kaspar.rohrer@gmail.com> 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/