Proposal: Improved error message of "Error in array index"
Malcolm.Wallace at cs.york.ac.uk
Tue Nov 8 09:43:47 EST 2005
Bulat Ziganshin <bulatz at HotPOP.com> writes:
> RdV> I suggest that the code in GHC.Arr be changed from
> RdV> error "Error in array index"
> RdV> to
> RdV> error "Error in array index" ++ show b ++ show i
> | also it will be cool to have ability to add such annotations to my own
> | functions, smthg like:
> | head (x:xs) = x
> | head  = superError "head "
> | which will print: "Error: head  in Module.hs:155"
Of course, there is the old stand-by C pre-processor trick:
#define superError(s) error (s++"\nin file "++__FILE__ \
++" at line "++__LINE__)
Whilst we are wishing for language features, I wonder if anyone
else would be interested in being able to export/import such cpp
macros using the normal Haskell module mechanism? At the moment,
it is ugly that you need to either #include or #define your macros
separately in every module where you use them. But if the cpp phase
were integrated more tightly into the compiler, it could be possible
to treat macros almost like ordinary function definitions.
More information about the Glasgow-haskell-users