ghci feature request: partially read modules

Stefan O'Rear stefanor at cox.net
Sat Feb 16 12:12:24 EST 2008


On Sat, Feb 16, 2008 at 04:53:24PM +0100, Johannes Waldmann wrote:
> Hello.
> 
> Here is one ghci feature that I find mildly annoying:
> 
> If ghci (re-)reads a module that contains some error,
> then it considers the module loading as a complete failure,
> and at the prompt I get the Prelude environment.
> 
> I'd like to have at least the import statements executed,
> and possibly the declarations that were error-free.
> That would help me in interactively debugging
> the erraneous part of the module.
> (Often the error is some type error, related to some imported entity;
> but when my module contains the error, then the imports are gone.)
> 
> Perhaps I'm doing something wrong, then please educate me;
> or perhaps there's an easy way to implement partial reading
> and typechecking. (It'd be enough to have this for the "current"
> module, of course.)
> 
> Thanks - Johannes Waldmann.

This is fairly easy for type errors - just have the 'type of expression'
function return errors using Either etc, and at the top level drop all
expressions with error type.

As for parse errors - good luck.  Haskell is incredibly difficult to
parse even if you ignore several of its less-friendly features.  If you
allow them... for a long time I said it had never even been proven
possible, but then I found a workable algorithm exponential in the file
size.  Now, how do you propose handling parse errors?  Here's an example
of why it's hardly trivial:

foo = x + y + z where {

x = 2;
y = 3;
z = 4;

}


Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20080216/e9588fb3/attachment.bin


More information about the Glasgow-haskell-users mailing list