> My program just died with the following message:
> 
> > Fail: Prelude.(!!): index too large
> 
> This is not very informative (I have 7000 LOC). The only 
> thing it tells
> me is that I should always check whether some index is ok or not, and
> produce a more informative error message by hand in the latter case.
> 
> Is there a more elegant way to figure out where the error occurred?
> Maybe a compiler switch that makes the program dump the source code
> position where (!!) was accessed?

Sadly no.  I've just been debugging Happy and got thoroughly annoyed about
the exact same thing.

Here are two ideas:  firstly, the new exception mechanism lets you trap
calls to error, including the above one.  By scattering 'tryAll' or whatever
throughout your program, you might get a better idea where the error is
occurring.  Secondly (and this isn't fully implemented yet, but I'm working
on it), the new profiling mechanism keeps track of the call chain during
execution, so hopefully we'll be able to get a better fix on run-time errors
by printing out the current cost-centre stack.

Cheers,
        Simon

Reply via email to