Proposal: Improved error message of "Error in array index"

Simon Marlow simonmar at
Tue Nov 8 06:12:09 EST 2005

On 08 November 2005 09:19, John Meacham wrote:

> jhc has a SRCLOC_ANNOTATE pragma to solve just this problem
> here is the relevant part of the docs:
>  * SRCLOC_ANNOTATE pragma. This is a generalization of GHCs assert
>    magic. A function which is given an SRCLOC_ANNOTATE pragma will be
>    replaced with an alternate version that takes the functions use
>    site as an argument. This allows error messages to be in terms of
>    where said function was used. The alternate function is named
>    [function]_srcloc_ann__ and must be in the same module as the
>    original function. Jhc does no checking to ensure both functions
>    have the same effect, it is up to the user to ensure that. An
> example is 

Nice - though it would be even better to provide the required
functionality automatically.

One idea that occurred to us recently is this: GHCi could provide a
simplified version of the cost-centre-stack machinery *all the time*,
giving you a proper backtrace for any exception, at least for the parts
of the call stack that are interpreted.  We don't care about the cost
too much - interpreted code is a lot slower than compiled already, and
it would only be a small constant factor.  I think this would be a huge
win for debuggability.  And a nice project for anyone who wants to hack
on the GHC internals - though not a small task by any means.


More information about the Glasgow-haskell-users mailing list