Heuristics to improve error messages for badly referenced things
I propose the implementation of fuzzy-matching heuristics so we can get errors like this:
Prelude> fsa
<interactive>:1:0:
Not in scope: `fsa'
Maybe you meant `fst'
Prelude> import Data.Lits
Could not find module `Data.Lits':
Use -v to see a list of the files searched for.
Maybe you meant `Data.Bits' or `Data.List'
Prelude>
And a heuristic such that when resolution of an unqualified name fails it can suggest a qualified alternative:
module Main where
import qualified Char
main = print (isSpace ' ')
$ stage2/ghc-inplace --make Test.hs
[1 of 1] Compiling Main ( Test.hs, Test.o )
Test.hs:4:14:
Not in scope: `isSpace'
Maybe you meant `Char.isSpace'
I believe both of these represent an improvement to the compiler user experience.
If you wish to implement this feature in GHC, I have implemented, documented and tested it already and the patches are attached. It is under flag control: use -fno-helpful-errors to disable it. This is turned by default for the testsuite.
Trac metadata
Trac field | Value |
---|---|
Version | 6.9 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | Unknown |
Architecture | Unknown |