[Haskell-cafe] Debugging methods for haskell
Don Stewart
dons at galois.com
Wed Jul 15 18:13:33 EDT 2009
fernanbolando:
> 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.
You could:
* use Debug.Trace.trace (equivalent of printf debugging)
* use asserts: the 'assert' function
* use the GHCi debugger to construct a stack trace
* use profiling to construct a stack trace.
* use the GHC head branch for first class stack traces, described
in, "Finding the needle: Stack Traces for GHC"
http://pubs.doc.ic.ac.uk/finding-the-needle/finding-the-needle.pdf
-- Don
More information about the Haskell-Cafe
mailing list