[commit: ghc] ghc-7.10: Expose source locations via Implicit Parameters of type GHC.Location.Location (e3dc280)

git at git.haskell.org git at git.haskell.org
Wed Jul 15 09:32:20 UTC 2015


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

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/e3dc28046373f3183dda56b096dbebec865e3be7/ghc

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

commit e3dc28046373f3183dda56b096dbebec865e3be7
Author: Eric Seidel <gridaphobe at gmail.com>
Date:   Mon Jan 19 16:08:32 2015 -0600

    Expose source locations via Implicit Parameters of type GHC.Location.Location
    
    IPs with this type will always be solved for the current source
    location. If another IP of the same type is in scope, the two locations will be
    appended, creating a call-stack. The Location type is kept abstract so users
    cannot create them, but a Location can be turned into a list of SrcLocs, which
    correspond to individual locations in a program. Each SrcLoc contains a
    package/module/file name and start/end lines and columns.
    
    The only thing missing from the SrcLoc in my opinion is the name of the
    top-level definition it inhabits. I suspect that would also be useful, but it's
    not clear to me how to extract the current top-level binder from within the
    constraint solver. (Surely I'm just missing something here?)
    
    I made the (perhaps controversial) decision to have GHC completely ignore
    the names of Location IPs, meaning that in the following code:
    
        bar :: (?myloc :: Location) => String
        bar = foo
    
        foo :: (?loc :: Location) => String
        foo = show ?loc
    
    if I call `bar`, the resulting call-stack will include locations for
    
    1. the use of `?loc` inside `foo`,
    2. `foo`s call-site inside `bar`, and
    3. `bar`s call-site, wherever that may be.
    
    This makes Location IPs very special indeed, and I'm happy to change it if the
    dissonance is too great.
    
    I've also left out any changes to base to make use of Location IPs, since there
    were some concerns about a snowball effect. I think it would be reasonable to
    mark this as an experimental feature for now (it is!), and defer using it in
    base until we have more experience with it. It is, after all, quite easy to
    define your own version of `error`, `undefined`, etc. that use Location IPs.
    
    Test Plan: validate, new test-case is testsuite/tests/typecheck/should_run/IPLocation.hs
    
    Reviewers: austin, hvr, simonpj
    
    Reviewed By: simonpj
    
    Subscribers: simonmar, rodlogic, carter, thomie
    
    Differential Revision: https://phabricator.haskell.org/D578
    
    GHC Trac Issues: #9049
    
    Cherry-Picked-From: c024af131b9e2538486eb605ba8af6a8d10fe76d
    Cherry-Picked-By: Niklas Hambüchen <niklas at fpcomplete.com>
    
    Changes for the cherry-pick:
    
    * Commit d2b6e767 "Make the location in TcLclEnv and CtLoc into a RealSrcSpan"
      was cherry-picked before to ensure that
        EvCsPushCall, EvCsTop :: EvCallStack
      can indeed carry `RealSrcSpan`s instead of `SrcSpan`s.
    * The use of `setWantedEvBind` was replaced by `setEvBind`, as
      `setWantedEvBind` is not yet present in 7.10.1; it was added to
      the 7.12 series in commit 32973bf3.
    * docs/users_guide/7.10.1-notes.xml was adjusted to contain the
      documentation about CallStack, copied from the 7.12 notes.


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

e3dc28046373f3183dda56b096dbebec865e3be7
 compiler/deSugar/DsBinds.hs                        |  62 +++++++-
 compiler/prelude/PrelNames.hs                      |  26 ++++
 compiler/typecheck/TcBinds.hs                      |   7 +-
 compiler/typecheck/TcEvidence.hs                   | 172 ++++++++++++++++++++-
 compiler/typecheck/TcExpr.hs                       |   6 +-
 compiler/typecheck/TcHsSyn.hs                      |   8 +
 compiler/typecheck/TcInteract.hs                   |  45 +++++-
 docs/users_guide/7.10.1-notes.xml                  |  43 ++++++
 docs/users_guide/glasgow_exts.xml                  |  50 ++++++
 libraries/base/GHC/SrcLoc.hs                       |  33 ++++
 libraries/base/GHC/Stack.hsc                       |  57 ++++++-
 libraries/base/base.cabal                          |   1 +
 testsuite/tests/typecheck/should_run/IPLocation.hs |  44 ++++++
 .../tests/typecheck/should_run/IPLocation.stdout   |  28 ++++
 testsuite/tests/typecheck/should_run/all.T         |   1 +
 15 files changed, 566 insertions(+), 17 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 e3dc28046373f3183dda56b096dbebec865e3be7


More information about the ghc-commits mailing list