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||Test Case:|
|Related Tickets:||Differential Rev(s):|
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")'
Change History (14)
Changed 9 years ago by jcpetruzza
comment:2 Changed 9 years ago by igloo
- difficulty set to Unknown
- Milestone set to 6.10.1
- Owner igloo deleted
comment:10 Changed 8 years ago by simonmar
- Resolution set to fixed
- Status changed from new to closed
comment:12 Changed 8 years ago by simonmar
- Operating System changed from Unknown to Unknown/Multiple