Debugging Arrays
Hal Daume III
hdaume@ISI.EDU
Wed, 8 Jan 2003 20:01:57 -0800 (PST)
If you're willing to use something other than Hugs, you're set. With GHC
or NHC you could use the HAT debugger (www.cs.york.ac.uk/fp/hat/). Or
even just with GHC if you compile with -prof -auto-all (for profiling),
you can run with +RTS -xc to get a stack backtrace on errors.
Otherwise, if you import IOExts, you can get poor-man's tracing by doing
something like: assume your original function looked like:
myfunc a b c = d
myfunc e f g = h
you could change this to:
myfunc a b c | trace ("entered myfunc " ++ show (a,b,c)) False = undefined
myfunc a b c = d
myfunc e f g = h
then you'll get these traces printed (of course you only show arguments
which are showable).
HTH
- Hal
--
Hal Daume III
"Computer science is no more about computers | hdaume@isi.edu
than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume
On Wed, 8 Jan 2003, Matthew Donadio wrote:
> Hi all,
>
> I am having a tough time debugging an array problem, and I was wondering
> if anyone had some pointers.
>
> I am working on a complicated function that relies on a few mutually
> recursive arrays (AR parameter estimation using Burg's Method). I am
> getting a runtime error, index: Index out of range, when I test out the
> function. For the life of me, I cannot figure out where the error is.
> One complication is that not all of the arrays elements are defined for
> the index bounds.
>
> I have tried several simplifications to isolate the arrays, but when I
> simplify too far, I run into type problems. Is there an easy way to
> trace execution? Does anyone have any advice on how to go about
> debugging this?
>
> I am using Hugs 98, November 2002 if it matters.
>
> Thanks.
>
> --
> Matthew Donadio (m.p.donadio@ieee.org)
> _______________________________________________
> Haskell mailing list
> Haskell@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
>