
19 Dec
2007
19 Dec
'07
2:50 p.m.
Georg Sauthoff
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