[GHC] #10925: GHC should inform where unknown identifiers originate whenever possible
GHC
ghc-devs at haskell.org
Fri Oct 2 12:00:23 UTC 2015
#10925: GHC should inform where unknown identifiers originate whenever possible
-------------------------------------+-------------------------------------
Reporter: hanshoglund | Owner:
Type: feature | Status: new
request |
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.2
Keywords: imports, | Operating System: Unknown/Multiple
error messages |
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): |
-------------------------------------+-------------------------------------
Assume I have a module Foo, using implicit imports and unqualified
identifiers (minimalistic example, actual cases could have hundreds of
imported modules).
{{{
module Foo
import Data.List
foo = intersperse ...
}}}
If I decide to switch to explicit imports, I have two options. I could
import Data.List as qualified, or add an explicit export list. In both
cases the origin of 'intersperse' will be unambiguous. If I choose
qualified imports, GHC will helpfully tell me where all now unqualified
identifiers originated.
{{{
Not in scope: type constructor or class ‘intersperse’
Perhaps you meant one of these:
‘Data.List.intersperse’
}}}
However, If I chose to add an explicit import list to the 'Data.List'
import, I will have no such help. Again, if the number of imported modules
is long, there is no obvious way to tell which module should have the
explicit import by just looking at the code. On the other hand, as the
above case shows GHC is obviously able to infer this. I can accomplish it
by manually duplicating my import list, and adding a qualified import of
every imported module, but this is a lot of manual work in modules with
many imports.
I suggest that for the purposes of error messages, top-level identifiers
not in scope should be searched for in every module as if it had been
imported qualified, and an error message akin to the following should be
generated. Obviously, if the identifier is availble from a a qualified
import, the above error message should take precedence.
{{{
Not in scope: type constructor or class ‘intersperse’.
It is available but not imported from the following modules:
‘Data.List.intersperse’
To bring the identifier into scope, import it from the one of the
above modules, or use a qualified import.
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10925>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list