[Haskell-cafe] How to make Prelude.read: no parse more verbose ...

Neil Mitchell ndmitchell at gmail.com
Wed Dec 19 15:17:39 EST 2007


Hi

> > 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.

I use the Safe library to do this sort of stuff:

http://www-users.cs.york.ac.uk/~ndm/safe/

You can call readMay to get a maybe result, or readNote which gives an
augmented error message on a crash. You can of course combine this
with the CPP trick:

#define read readNote (__FILE__++":"++show __LINE__)

Thanks

Neil


More information about the Haskell-Cafe mailing list