[Claus Reinke] [Summary] [Paper] [Distribution] [Status] [Applets] [Online Examples]
a Java-based graphical observation event viewer, building on Andy Gill's Hood (Haskell Object Observation Debugger).
Summary: GHood is a graphical back-end for Hood, the front-end (the Haskell interface) is precisely that of Hood. If you have been using Hood already you won't have to change your programs to switch to GHood. If you haven't used Hood before, you can employ all the nice definitions in Hood's Observe library, just as explained in the Hood documentation (see the Hood homepage at haskell.org).
To get hold of the stream of observation events collected by Hood, we modify Observe.lhs so that just before Hood post-processes its observations for pretty-printing, the stream of observation events is written to a file (ObserveEvents.log), and a Java-based graphical event viewer is started. This viewer is the major new aspect in GHood and supports the animation of data structure observations. GHood uses a simple tree layout algorithm (Hood does not observe sharing, so this is sufficient) and colour-coded nodes (blue for observation labels, red for unobserved/unevaluated thunks, yellow for thunks under observation/evaluation, black for observed/evaluated structures in weak head normal form, white for functions). Scaling of observation trees and replay control facilities further support programmers in their attempts to get an overview of static and dynamic observations (structures and strictness properties, as exposed by the order of observations).
Paper: GHood -- Graphical Visualisation and Animation of Haskell Object Observations, Claus Reinke, ACM SIGPLAN Haskell Workshop, Firenze, Italy, 2nd September 2001
Distribution: GHood is now available on hackage (thanks to Hugo Pacheco)
Status: The viewer should be straightforward to use: Exit exits the viewer session (Hood will pretty-print its observations); Print tries to print the current view, but still lacks the proper scaling; Reset resets the viewer to the beginning of the observation, Play animates the observations, Stop stops the animation, single-stepping forwards and backwards through the animation is also possible. Two sliders allow to scale the view and to set the delay after each observation event.. That's it.
Apart from the examples from the Hood documentation, and the Hood tests in the Haskell CVS repository (the biggest test so far had some 2500 events, which is non-trivial, but not really big..), I found it quite interesting to observe the strictness properties of various solutions to Chris Okasaki's breadth-first renumbering problem. But I won't spoil the fun by giving the code here (for the problem and discussion, see Chris' paper in ICFP 2000). To visualise the strictness properties of a solution, just observe the trees before and after renumbering. Compare what you see with what you expect.
Applets:GHood can also be used as an applet. Some users might find it easier to set up GHood in their browser than as a stand-alone program, but the major intended use is for online documentation purposes: you can now write a webpage explaining the behaviour of some Haskell programs, and have a GHood applet on the page that demonstrates what you are talking about!
Here is an example code fragment, showing the use of GHood as an applet:
<APPLET CODE = "GHood.class" ARCHIVE = "GHood.jar" WIDTH = 750 HEIGHT = 320 ALT = "you should see an instance of GHood here, as an applet"> <PARAM NAME = "eventSource" VALUE ="ObserveEvents.log"> <PARAM NAME = "delay" VALUE ="150"> <PARAM NAME = "scale" VALUE ="75"> </APPLET>As usual, you give the class to be loaded (GHood.class), the place where it can be found (GHood.jar in the current directory), the width and height. Additional parameters for GHood are the source location for the observations to be animated (interpreted relative to the URL of the current document), the delay (in ms) after each step, and the scale (between 0 and 200%).
GHood uses Swing (Java 2's current GUI library), which still isn't supported directly in many browsers, although the most popular ones can be configured to support this. One option is the Java-Plugin distributed by Sun free of charge. If you have a Java distribution that can run GHood, chances are that you've got this plugin already. Sun also distributes a Java Plug-in HTML-converter that obfuscates the code fragments in <APPLET> tags (as a side-effect, the converted code is supposed to do the right thing to start the plugin on the most popular platforms..).
Online Examples: The following pages should give you some idea of how GHood can be used as an applet (each page contains two applets, which may take some time to load; if your browser doesn't support Java 2, and certain other mysterious conditions are fulfilled, you might find yourself directed to a suitable download page for the plug-in; well, what shall I say, just try to follow the link and see what happens;-):
foldr (+) 0 [1..4]
foldl (+) 0 [1..4]
foldl' (+) 0 [1..4]Note the chains of yellow thunks --objects under observation, but not yet with observable structures, and when these chains start to shrink, relative to the observation of the parameter list.
If GHood applets shouldn't work for you, I will probably not be able to do much about it, unless it involves a GHood-specific problem, but I would like to hear about any problems anyway. So far, I have seen these pages working under Windows NT (both Internet Explorer and Netscape), Windows 98 (Internet Explorer), Sun Solaris (Netscape), and Linux (Netscape 6).