[commit: ghc] master: Re-work the naming story for the GHCi prompt (Trac #8649) (73c08ab)

git at git.haskell.org git at git.haskell.org
Fri Jan 10 08:52:21 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/73c08ab10e4077e18e459a1325996bff110360c3/ghc

>---------------------------------------------------------------

commit 73c08ab10e4077e18e459a1325996bff110360c3
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Thu Jan 9 17:58:18 2014 +0000

    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.


>---------------------------------------------------------------

73c08ab10e4077e18e459a1325996bff110360c3
 compiler/basicTypes/Module.lhs       |   23 ++-
 compiler/basicTypes/Name.lhs         |   18 +-
 compiler/basicTypes/RdrName.lhs      |    4 +-
 compiler/deSugar/Desugar.lhs         |    3 +-
 compiler/ghci/Linker.lhs             |   16 +-
 compiler/ghci/RtClosureInspect.hs    |    6 +-
 compiler/iface/IfaceEnv.lhs          |   18 +-
 compiler/llvmGen/LlvmCodeGen/Base.hs |    4 +-
 compiler/main/DynamicLoading.hs      |   22 ++-
 compiler/main/HscMain.hs             |   32 ++--
 compiler/main/HscTypes.lhs           |  329 ++++++++++++++++++++++------------
 compiler/prelude/PrelNames.lhs       |    9 +-
 compiler/rename/RnEnv.lhs            |   23 +--
 compiler/rename/RnNames.lhs          |    2 +-
 compiler/simplCore/CoreMonad.lhs     |    2 +-
 compiler/typecheck/FamInst.lhs       |    4 +-
 compiler/typecheck/TcEnv.lhs         |   13 +-
 compiler/typecheck/TcRnDriver.lhs    |  196 +++++++++-----------
 compiler/typecheck/TcRnMonad.lhs     |   23 ++-
 compiler/typecheck/TcRnTypes.lhs     |    4 +
 compiler/typecheck/TcSplice.lhs      |   17 +-
 compiler/types/FamInstEnv.lhs        |   13 +-
 compiler/utils/Outputable.lhs        |   30 ++--
 23 files changed, 452 insertions(+), 359 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 73c08ab10e4077e18e459a1325996bff110360c3


More information about the ghc-commits mailing list