[GHC] #11418: Suggest correct spelling when module is not found because of typo

GHC ghc-devs at haskell.org
Wed Jan 13 09:24:58 UTC 2016


#11418: Suggest correct spelling when module is not found because of typo
-------------------------------------+-------------------------------------
        Reporter:  syd               |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  lowest            |            Milestone:
       Component:  Compiler          |              Version:
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by syd:

Old description:

> Given these two modules:
>
> Aaa.hs:
> {{{#!hs
> module Aaa where
>
> import           BBb
>
> main :: IO ()
> main = putStrLn myString
> }}}
>
> Bbb.hs:
> {{{#!hs
> module Bbb where
>
> myString :: String
> myString = "hi"
> }}}
>
> There's a typo in `Aaa.hs`, the import should be `Bbb` instead of `BBb`.
>
> Running `runhaskell Aaa.hs` results in this error:
>
> {{{
> Aaa.hs:3:18:
>     Could not find module ‘BBb’
>     Use -v to see a list of the files searched for.
> }}}
>
> The request is to have the compiler suggest that this is a typo and that
> it should be `Bbb` instead.
> It already does this for misspelled functions, if I recall correctly.
>
> Because the compiler will not continue when finding an error like this,
> it won't be harmful to spend a little extra time looking for possible
> misspellings.
>
> How typo's should be recognized is something that should be fleshed out
> later. For example, a hamming distance of 2 or less could indicate a
> typo.

New description:

 Given these two modules:

 Aaa.hs:
 {{{#!hs
 module Aaa where

 import           BBb

 main :: IO ()
 main = putStrLn myString
 }}}

 Bbb.hs:
 {{{#!hs
 module Bbb where

 myString :: String
 myString = "hi"
 }}}

 There's a typo in `Aaa.hs`, the import should be `Bbb` instead of `BBb`.

 Running `runhaskell Aaa.hs` results in this error:

 {{{
 Aaa.hs:3:18:
     Could not find module ‘BBb’
     Use -v to see a list of the files searched for.
 }}}

 The request is to have the compiler suggest that this is a typo and that
 it should be `Bbb` instead.
 It already does this for misspelled functions, if I recall correctly.

 Because the compiler will not continue when finding an error like this, it
 won't be harmful to spend a little extra time looking for possible
 misspellings.

 How typo's should be recognized is something that should be fleshed out
 later. For example, a hamming distance of 2 or less could indicate a typo.

 I'd like to pick this one up and try to implement it as my first patch to
 GHC.

--

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11418#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list