[Haskell-cafe] Debugging

Jules Bean jules at jellybean.co.uk
Thu May 10 05:19:15 EDT 2007


Ryan Dickie wrote:
>
> I've only written trivial applications and functions in haskell. But 
> the title of this thread got me thinking.
>
> In an imperative language you have clear steps, states, variables to 
> watch, etc.
> What techniques/strategies might one use for a functional language?


Well, breakpoints and traces exist, and they're useful, as Stefan showed.

However in the presence of a decent repl (ghci) and a useful type 
system, I most often find myself debugging by trying out my functions in 
the repl.

If your problem is nicely broken down, you can test the smallest 
functions first, see if they are behaving as expected, and then work up.

The 'next step' is to move from testing by hand in ghci to writing 
quickcheck properties / smallcheck / unit tests for the functions.

You'll find the need for imperative-style debugging techniques 
surprisingly infrequent.

Jules



More information about the Haskell-Cafe mailing list