Add a flag to disable the implicit qualified import of every available module in interactive mode
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")'
|Component||Compiler (Type checker)|