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

Johannes Waldmann waldmann at
Mon Nov 7 11:30:46 EST 2005

Rene de Visser wrote:
> I suggest that the code in GHC.Arr be changed ... to
> error "Error in array index" ++ show b ++ show i

This would introduce  Show  constraints for (!) everywhere
which probably is undesirable as it would break code.

I had to trace a similar error recently
and I ended up writing a module
that imports Data.Array and re-exports everything
except (!)  which I replaced with a version like the one above.

Slightly unrelated,

it is generally a good idea not to import system libraries
(e. g. Data.*) in too many places because the application program
should define its own abstractions (which can then be implemented
using the pre-defined abstractions from Data.* but this should be

Unnecessary exposure of implementation details
is called "primitive obsession"  by the OO design folks, see e. g.

You might object that if everyone writes his own types for everything,
then there can be no generally useful libraries (since they don't know
the types) but of course there can - relying on a well-defined set of
interfaces (type classes) that user-defined types can implement.

Best regards,
-- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 --
---- -------

More information about the Glasgow-haskell-users mailing list