
g_sauthoff:
Hi,
I try to debug some existing Haskell-Code. Out of the blue I get a 'progname: Prelude.read: no parse' error message from GHC.
Great.
Well, the code includes
# grep '\
' *| wc -l 23 (sic!) calls to the read fn.
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.
Really crazy would be the possibility to print out a backtrace, if some (library) function calls error ...
ghci now has a debugger that can backtrace like this, see this blog post for more details. http://cgi.cse.unsw.edu.au/~dons/blog/2007/11/14#no-exceptions using reads or even read lifted to a monad, like this, can be very useful, if it is code you control: readM :: (Monad m, Read a) => String -> m a readM s = case [x | (x,t) <- reads s, ("","") <- lex t] of [x] -> return x [] -> fail "readM: no parse" _ -> fail "readM: ambiguous parse" since you can handle failure without throwing an async exception. -- Don