[Haskell-cafe] Debugging methods for haskell
magnus at therning.org
Thu Jul 16 10:56:51 EDT 2009
On Wed, Jul 15, 2009 at 11:13 PM, Don Stewart<dons at galois.com> wrote:
>> 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"
Another option would be to use Safe.atMay instead of !!.
Magnus Therning (OpenPGP: 0xAB4DFBA4)
magnus＠therning．org Jabber: magnus＠therning．org
http://therning.org/magnus identi.ca|twitter: magthe
More information about the Haskell-Cafe