[Haskell-cafe] Human-friendly compiler errors for GHC

Max Bolingbroke batterseapower at hotmail.com
Sat Jul 12 14:15:26 EDT 2008


2008/7/12 Evan Laforge <qdunkan at gmail.com>:
>> What do you think about this feature? Would it be genuinely helpful or annoying?
>
> It could be handy if it understands qualified names.  Occasionally
> typos e.g. just now Confg.default_x are surprisingly hard to see and I
> go around making sure Config is imported, making sure it exports
> default_x, etc. before finally figuring it out.

Good point.

It turns out that actually since my implementation doesn't include
module names in the match at all, this works without writing more code
on my part. But perhaps I should make it module-aware as I think that
will allow more accurate matching.

I've also changed the output format and tweaked the match threshold
algorithm, with this result:
""
mbolingbroke at Equinox ~/Programming/Checkouts/ghc.working/compiler
$ stage2/ghc-inplace --interactive -fhelpful-errors
GHCi, version 6.9.20080711: http://www.haskell.org/ghc/  :? for help
Prelude> let foo = 10
Prelude> foa

<interactive>:1:0:
    Not in scope: `foa'
    Maybe you meant `foo'
Prelude> fts

<interactive>:1:0:
    Not in scope: `fts'
    Maybe you meant `fst'
Prelude> let foa = 20
Prelude> fof

<interactive>:1:0:
    Not in scope: `fof'
    Maybe you meant `foo' or `foa'

Prelude> import Data.Lost
Could not find module `Data.Lost': -- Maybe it should do something better here..
  Use -v to see a list of the files searched for.
Prelude> :q

$ stage2/ghc-inplace --make Test.hs
[1 of 1] Compiling Main             ( Test.hs, Test.o )

Test.hs:5:14:
    Not in scope: `Chbr.isSpoce'
    Maybe you meant `Char.isSpace'
"""

Max


More information about the Haskell-Cafe mailing list