[Haskell-beginners] Rank beginner question about debugging

Brent Yorgey byorgey at seas.upenn.edu
Tue Jul 21 22:43:30 EDT 2009


On Tue, Jul 21, 2009 at 09:26:19AM -0400, Ben Wise wrote:
> Folks,
> 
> I'm a rank beginner in Haskell, and though Haskell seems like a great
> language to start using, I've got a serious concern about debugging.
> 
> In about 15 years of Lisp experience, then 15 years of C++, I've gotten
> pretty accustomed to the idea of using a debugger with lots of pre- and
> post-conditions on functions, breakpoints, stack trace, and variable
> inspection -- even though it gets tricky with delayed evaluation,
> macros, etc. in Lisp!

If you think it's tricky in Lisp, it's about ten times as tricky with
a lazy language like Haskell!  Using gdb with Haskell executables is
pretty much useless since the generated code doesn't correspond to the
Haskell code in any obvious ways.  And it's really hard to make
traditional debuggers since the ghc runtime model looks nothing like
traditional ones.  However, There IS a debugger built into most recent
versions of ghci which lets you do some of these things -- have you
taken a look at that?

I've done quite a bit of programming using the sort of debuggers you
describe myself---with C, C++, and Java in particular.  And yet in all
the Haskell coding I've done over the past few years---some of it
quite significant---I've rarely missed those sorts of debuggers.  I'm
not quite sure I understand the reason why.  Perhaps it's partly
because Haskell lets you program on such a high level that there's
less room for the sorts of titchy errors that debuggers are so good at
helping you find.  In any case, I wouldn't worry about it too much at
this point if I were you, and if you really do find yourself wanting
it, take a look at the ghci debugger.

-Brent


More information about the Beginners mailing list