Ticket #2452 (closed feature request: fixed)
Add a flag to disable the implicit qualified import of every available module in interactive mode
|Reported by:||jcpetruzza||Owned by:||simonmar|
|Component:||Compiler (Type checker)||Version:||6.9|
|Type of failure:||None/Unknown||Difficulty:||Unknown|
|Test Case:||Blocked By:|
In interactive mode every available module is implicitly imported qualified. While this is very convenient when working with GHCi, it can be a little annoying in other contexts.
For instance, in a lambdabot-like application, one would like to rely on the type of a given expression to decide if it is side-effect free and, thus, safe to execute. However, because every module in the base package is imported qualified one has to do a manual check to filter out cases like:
ghc -e 'System.IO.Unsafe.unsafePerformIO (evilStuff >> return "i'm an innocent string")'
Another example would be a GHC-API based refactoring tool that wants to check if a refactored expression typechecks before modifying the code. If every module is imported qualified, the tool might get many false positives.
The proposal is to keep the current behaviour as the default but to add a -fno-implicit-import-qualified flag to disable it when needed. The following should fail to execute:
ghc -fno-implicit-import-qualified -e 'System.IO.Unsafe.unsafePerformIO (evilStuff >> return "i'm an innocent string")'