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

Simon Marlow simonmar at
Wed Nov 9 08:35:20 EST 2005

On 09 November 2005 11:52, Olaf Chitil wrote:

> Simon Marlow wrote:
>> I can explain why it happens,
>> though.  The compiler has lifted out the error case into a top-level
>> binding: 
>>  x = error "Error in array index"
> So cost-centre stacks are not produced for the original program
> written by the user, but for the intermediate program after
> optimisation. I understand that you want to profile the optimised
> version, but the fact that your profile does not quite match your
> program can be confusing. For debugging, however, I think that it is
> clear that you want your debugging information (cost centre stacks)
> to match your program, even if it costs you some performance.

I completely agree!  Indeed, the simplifier does try to maintain the
shape of the call graph when it transforms the program (perhaps not
entirely successfully).

The issue here I think is that we should treat exceptions in a similar
way to functions: when a function is called, the cost-centre stack of
the function is appended to the cost-centre stack of the call site, this
is how the call graph is built up.  A thunk which evaluates to an
exception should probably behave in the same way, which would fix the
problem above (I'm not sure how easy this is to do, though).


More information about the Glasgow-haskell-users mailing list