Ketil Malde | 19 Dec 20:50
Picon
Picon

Re: How to make Prelude.read: no parse more verbose ...

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

Gmane