[Haskell-cafe] Re: Debugging methods for haskell

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Thu Jul 16 04:10:22 EDT 2009


Fernan Bolando <fernanbolando at mailc.net> writes:

> Hi all
>
> I recently used 2 hours of work looking for a bug that was causing
>
> Program error: Prelude.!!: index too large
>
> This is not very informative. It did not give me a hint which function
> was causing this. In C adding a few printf would have helped me, but
> in haskell I was not sure how to do that. Can anybody point me to some
> debuggin method everyone uses.
>
> After 2 hours I did find the bug eventually. The code can be viewed here.
> Maybe some reformatting of the code would make finding bugs easier?
> http://plan9.bell-labs.com/sources/contrib/fernan/escomma/

I wonder if your code has to use !! at all? I took a look at a random
module from the above link, and (without making much attempt at
understanding it), I'd guess that using accumArray and friends would be
more appropriate. Mostly you don't want to be doing indexing on lists.

-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk




More information about the Haskell-Cafe mailing list