[commit: ghc] wip/spj-tc-branch: Type inference improvements for higher rank (c0346ae)

git at git.haskell.org git at git.haskell.org
Wed Aug 31 16:44:16 UTC 2016


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

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

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

commit c0346aeac2770cfef929ed9c8e5f99f2ec0e9cff
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Tue Aug 30 11:00:47 2016 +0100

    Type inference improvements for higher rank
    
    This is a draft patch
    
    1. Modify TcType.ExpType to make a distinct data type,
       InferResult for the Infer case.
    
    2. Define a new function TcUnify.fillInferResult, to fill in
       an InferResult. Crucially, it calls new function
       TcMType.promoteTcType to the magic of exposing higher rank stuff
       See Note [Promoting a type] in TcMType
    
    3. Add a TcLevel to SkolemTvs. This will be useful generally
        - it's a fast way to see if the type
          variable escapes when floating
        - it provides a good consistency check when updating a
          unification variable
       But my reason for doing it now is that it allows me to be
       more selective about cloning in promoteTcType.  It's not
       essential, but I've been meaning to do this for some time.
    
    4. Reduce and simplify the plethora of tcSubType functions in
       TcUnify.  But the main change is that tcSubTypeDS_NC_O, in
       the Infer case, does deep instantiation before calling
       fillInferResult.  Reason:
           f :: (?x :: Int) => a -> a
    
           g y = let ?x = 3::Int in f
    
    Open problem: the cloning in promoteTc should not happen
    under GADT-style type equalities.  Boo..


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

c0346aeac2770cfef929ed9c8e5f99f2ec0e9cff
 compiler/typecheck/TcBinds.hs                      |   2 +-
 compiler/typecheck/TcExpr.hs                       |   9 +-
 compiler/typecheck/TcHsType.hs                     |  13 +-
 compiler/typecheck/TcInstDcls.hs                   |   3 +-
 compiler/typecheck/TcMType.hs                      | 261 +++++++++++++++------
 compiler/typecheck/TcPatSyn.hs                     |   8 +-
 compiler/typecheck/TcType.hs                       |  70 ++++--
 compiler/typecheck/TcUnify.hs                      | 232 +++++++++---------
 compiler/typecheck/TcValidity.hs                   |   2 +-
 compiler/vectorise/Vectorise/Generic/PData.hs      |   2 +-
 .../typecheck/should_compile/ExPatFail.stderr      |   6 +-
 .../tests/typecheck/should_compile/tc141.stderr    |   2 +-
 testsuite/tests/typecheck/should_fail/T3102.hs     |   2 +-
 .../tests/typecheck/should_fail/tcfail004.stderr   |   6 +-
 .../tests/typecheck/should_fail/tcfail005.stderr   |   6 +-
 .../tests/typecheck/should_fail/tcfail018.stderr   |   2 +-
 16 files changed, 382 insertions(+), 244 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 c0346aeac2770cfef929ed9c8e5f99f2ec0e9cff


More information about the ghc-commits mailing list