
2008/7/13 Isaac Dupree
wren ng thornton wrote:
In terms of making error messages more helpful, I don't find general typos are much of an issue, but this part would be really nice! I've always been annoyed that GHC just says "no" rather than offering suggestions (-v is rarely helpful), especially since it knows about what modules are installed et al.
It sounds like it only searches for modules you've imported (after all they might've been brought into scope with an as-clause, and ghc has no business poking in un-imported modules), but perhaps since in GHCi all modules are in scope (under their original names -- in addition to any imports in an interpreted file), it (ghci) searches all modules then?
You're right: if there is no qualified import of Char then it won't suggest Char.isSpace. The reason for this is that doing so would require GHC to load all the interface files for all exposed modules on disk in order to search exported names, which doesn't sound like a great idea performance-wise. The same thing applies to GHCi.
If I want a "perhaps you meant to import" message, I want it to be a *complete* listing of modules available that export that symbol, both local ones and library ones, ideally :-) (certainly don't want a recommendation to import e.g. List without at least an equal recommendation of Data.List...)
I agree this feature would be cool, I'm just not sure the possible memory/performance problems associated with loading all interfaces of all exposed modules in all packages (it would be most helpful but even more of a performance problem to even scan non-exposed packages) would be worth it. Probably it could be made practical by building a sort of index, which is cached on disk.. Max