Skip to content

Suggest correct spelling when module is not found because of typo

Given these two modules:

Aaa.hs:

module Aaa where

import           BBb

main :: IO ()
main = putStrLn myString

Bbb.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.

Edited by Mr Kerckhove
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information