Debugging

Brandon Michael Moore brandon@its.caltech.edu
Wed, 27 Aug 2003 22:05:30 -0700 (PDT)


On Tue, 26 Aug 2003, Konrad Hinsen wrote:

> My Haskell experiments have reached a size in which debugging tools would be
> more than welcome, so I looked around, and was very disappointed. I tried
> Hood, which is a pain to use (lots of editing of the code required), I looked
> at Buddha but didn't want to downgrade to GHC 5 for trying it (nor is my code
> Haskell 98, because of multi-parameter classes), and all that seems left to
> try is Hat, whose Web site I can't reach at the moment.
>
> So what are you Haskell programmers using for debugging in real life?
>
> Konrad.

What are you trying to debug? I could write something that sounded more
relevant if I knew.

I haven't been doing anything that counts as real life programming, so my
suggestions are probably biased towards trivial programs and low standards
of correctness. In particular, I've never worried about space leaks. My
advice is basically design suggestions and QuickCheck.

Mostly I try to write my programs in small pieces and check those. It's
not exactly debugging, but it makes debugging a lot easier. For trivial
throwaway programs testing by hand in GHCI is enough (It's been enough for
solving some old ACM problems. I love ReadP, and the monad transformers).
QuickCheck gives a much better indication of correctness with much less
manual labor. IIRC I used it when writing a unifier.

I don't know how to test a GUI with QuickCheck, or custom monads (Browser,
JVM, etc. custom=not in a typeclass, so you can't define a stub), but
other than that I think it's the best thing short of a proof, and it has
the advantage of being machine checked.  Has anyone tried to write a
system that would prove QuickCheck style properties from a function
definition?

The only tool I've used is HOOD. The version online needs a bit of hacking
to work with GHC 6 (you need to resolve catch to Control.Exception.catch
and fix some types). I like the output, and I didn't think the code
changes were too bad. I had some trouble defining Observable instances
when I was coding examples from "Recursion Schemes from Comonads", but I
doubt your types are quite as convoluted (think DecoratingStructures at
the type level). Do you want to avoid ANY code changes?

Brandon