Re-work the naming story for the GHCi prompt (Trac #8649)
The basic idea here is simple, and described in Note [The interactive package] in HscTypes, which starts thus: Note [The interactive package] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Type and class declarations at the command prompt are treated as if they were defined in modules interactive:Ghci1 interactive:Ghci2 ...etc... with each bunch of declarations using a new module, all sharing a common package 'interactive' (see Module.interactivePackageId, and PrelNames.mkInteractiveModule). This scheme deals well with shadowing. For example: ghci> data T = A ghci> data T = B ghci> :i A data Ghci1.T = A -- Defined at <interactive>:2:10 Here we must display info about constructor A, but its type T has been shadowed by the second declaration. But it has a respectable qualified name (Ghci1.T), and its source location says where it was defined. So the main invariant continues to hold, that in any session an original name M.T only refers to oe unique thing. (In a previous iteration both the T's above were called :Interactive.T, albeit with different uniques, which gave rise to all sorts of trouble.) This scheme deals nicely with the original problem. It allows us to eliminate a couple of grotseque hacks - Note [Outputable Orig RdrName] in HscTypes - Note [interactive name cache] in IfaceEnv (both these comments have gone, because the hacks they describe are no longer necessary). I was also able to simplify Outputable.QueryQualifyName, so that it takes a Module/OccName as args rather than a Name. However, matters are never simple, and this change took me an unreasonably long time to get right. There are some details in Note [The interactive package] in HscTypes.
Showing
- compiler/basicTypes/Module.lhs 14 additions, 9 deletionscompiler/basicTypes/Module.lhs
- compiler/basicTypes/Name.lhs 9 additions, 9 deletionscompiler/basicTypes/Name.lhs
- compiler/basicTypes/RdrName.lhs 1 addition, 3 deletionscompiler/basicTypes/RdrName.lhs
- compiler/deSugar/Desugar.lhs 1 addition, 2 deletionscompiler/deSugar/Desugar.lhs
- compiler/ghci/Linker.lhs 7 additions, 9 deletionscompiler/ghci/Linker.lhs
- compiler/ghci/RtClosureInspect.hs 5 additions, 1 deletioncompiler/ghci/RtClosureInspect.hs
- compiler/iface/IfaceEnv.lhs 5 additions, 13 deletionscompiler/iface/IfaceEnv.lhs
- compiler/llvmGen/LlvmCodeGen/Base.hs 2 additions, 2 deletionscompiler/llvmGen/LlvmCodeGen/Base.hs
- compiler/main/DynamicLoading.hs 15 additions, 11 deletionscompiler/main/DynamicLoading.hs
- compiler/main/HscMain.hs 20 additions, 12 deletionscompiler/main/HscMain.hs
- compiler/main/HscTypes.lhs 210 additions, 119 deletionscompiler/main/HscTypes.lhs
- compiler/prelude/PrelNames.lhs 3 additions, 6 deletionscompiler/prelude/PrelNames.lhs
- compiler/rename/RnEnv.lhs 12 additions, 11 deletionscompiler/rename/RnEnv.lhs
- compiler/rename/RnNames.lhs 1 addition, 1 deletioncompiler/rename/RnNames.lhs
- compiler/simplCore/CoreMonad.lhs 1 addition, 1 deletioncompiler/simplCore/CoreMonad.lhs
- compiler/typecheck/FamInst.lhs 8 additions, 6 deletionscompiler/typecheck/FamInst.lhs
- compiler/typecheck/TcEnv.lhs 8 additions, 11 deletionscompiler/typecheck/TcEnv.lhs
- compiler/typecheck/TcRnDriver.lhs 88 additions, 108 deletionscompiler/typecheck/TcRnDriver.lhs
- compiler/typecheck/TcRnMonad.lhs 14 additions, 9 deletionscompiler/typecheck/TcRnMonad.lhs
- compiler/typecheck/TcRnTypes.lhs 4 additions, 0 deletionscompiler/typecheck/TcRnTypes.lhs
Loading
Please register or sign in to comment