[commit: ghc] wip/spj-tc-branch2: More typechecker refactoring (e9caca9)

git at git.haskell.org git at git.haskell.org
Thu Sep 29 10:36:08 UTC 2016


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

On branch  : wip/spj-tc-branch2
Link       : http://ghc.haskell.org/trac/ghc/changeset/e9caca936fc0ab0b41eb2d9c3bd3a5cbbccf7910/ghc

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

commit e9caca936fc0ab0b41eb2d9c3bd3a5cbbccf7910
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Tue Sep 20 23:31:07 2016 +0100

    More typechecker refactoring
    
    This patch fixes one (un-reported) bug, and does a
    useful tidy-ups in the type checker
    
    1. Kill off tcs_used_tcvs.  Its purpose is to track the
       givens used by wanted constraints.  For dictionaries etc
       we do that via the free vars of the /bindings/ in the
       implication constraint ic_binds.  But for coercions we
       just do update-in-place in the type, rather than
       generating a binding.  So we need something analogous to
       bindings, to track what coercions we have added.
    
       That was the purpose of tcs_used_tcvs.  But it only
       worked for a /single/ iteration, whereas we may have
       multiple iterations of solving an implication.  Look
       at (the old) 'setImplicationStatus'.  If the constraint
       is unsolved, it just drops the used_tvs on the floor.
       If it becomes solved next time round, we'll pick up
       coercions used in that round, but ignore ones used in
       the first round.
    
       There was an outright bug.  Result = (potentialy) bogus
       unused-constraint errors.  Constructing a case where this
       actually happens seems quite trick so I did not do so.
    
       Solution: expand EvBindsVar to include the (free vars of
       the) coercions, so that the coercions are tracked in
       essentially the same way as the bindings.
    
       This turned out to be much simpler.  Less code, more
       correct.
    
    2. Make the ic_binds field in an implication have type
          ic_binds :: EvBindsVar
       instead of (as previously)
          ic_binds :: Maybe EvBindsVar
       This is notably simpler, and faster to use -- less
       testing of the Maybe.  But in the occaional situation
       where we don't have anywhere to put the bindings, the
       belt-and-braces error check is lost.  So I put it back
       as an ASSERT in 'setImplicationStatus' (see the use of
       'termEvidenceAllowed')


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

e9caca936fc0ab0b41eb2d9c3bd3a5cbbccf7910
 compiler/typecheck/TcErrors.hs   |  38 ++++++------
 compiler/typecheck/TcEvidence.hs |  33 +++++++++--
 compiler/typecheck/TcHsSyn.hs    |   5 +-
 compiler/typecheck/TcInstDcls.hs |   4 +-
 compiler/typecheck/TcPluginM.hs  |  16 +----
 compiler/typecheck/TcRnDriver.hs |   9 +--
 compiler/typecheck/TcRnMonad.hs  |  28 +++++----
 compiler/typecheck/TcRnTypes.hs  |  27 +++++----
 compiler/typecheck/TcSMonad.hs   | 124 ++++++++++++++++-----------------------
 compiler/typecheck/TcSimplify.hs |  58 +++++++++---------
 compiler/typecheck/TcUnify.hs    |   2 +-
 11 files changed, 170 insertions(+), 174 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 e9caca936fc0ab0b41eb2d9c3bd3a5cbbccf7910


More information about the ghc-commits mailing list