19 Dec 20:50
Re: How to make Prelude.read: no parse more verbose ...
Ketil Malde <ketil+haskell <at> ii.uib.no>
2007-12-19 19:50:23 GMT
2007-12-19 19:50:23 GMT
Georg Sauthoff <g_sauthoff <at> web.de> writes:
> Well, how do I compile a Haskell program in such a way, that I
> get a useful error message from read? I mean, like the
> filename/linenumber of the calling expression for starters.
It's dirty, it's mean, but you can use CPP. (On one line, and with
ghc -cpp):
#define read (\s -> case [ x | (x,t) <- reads s, ("","") <- lex t] of
{ [x] -> x ;
[] -> error("read: no parse at "++__FILE__++":"++show __LINE__);
_ -> error("read: no parse at "++__FILE__++":"++show __LINE__)})
-k
--
--
If I haven't seen further, it is by standing in the footprints of giants
RSS Feed