[commit: ghc] master: Implement full co/contra-variant subsumption checking (fixes Trac #9569) (b685542)

git at git.haskell.org git at git.haskell.org
Fri Nov 21 13:03:03 UTC 2014


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

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

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

commit b6855422fd532e5988fc98764c5cc47acbefbfb8
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri Nov 21 10:58:10 2014 +0000

    Implement full co/contra-variant subsumption checking (fixes Trac #9569)
    
    This is a pretty big patch, but which substantially iproves the subsumption
    check.  Trac #9569 was the presenting example, showing how type inference could
    depend rather delicately on eta expansion.  But there are other less exotic
    examples; see Note [Co/contra-variance of subsumption checking] in TcUnify.
    
    The driving change is to TcUnify.tcSubType.  But also
    
    * HsWrapper gets a new constructor WpFun, which behaves very like CoFun:
           if     wrap1 :: exp_arg <= act_arg
                  wrap2 :: act_res <= exp_res
           then   WpFun wrap1 wrap2 : (act_arg -> arg_res) <= (exp_arg -> exp_res)
    
    * I generalised TcExp.tcApp to call tcSubType on the result,
      rather than tcUnifyType.  I think this just makes it consistent
      with everything else, notably tcWrapResult.
    
    As usual I ended up doing some follow-on refactoring
    
    * AmbigOrigin is gone (in favour of TypeEqOrigin)
    * Combined BindPatSigCtxt and PatSigCxt into one
    * Improved a bit of error message generation


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

b6855422fd532e5988fc98764c5cc47acbefbfb8
 compiler/deSugar/DsBinds.lhs      |   9 +-
 compiler/deSugar/Match.lhs        |   1 +
 compiler/typecheck/Inst.lhs       |  14 +--
 compiler/typecheck/TcBinds.lhs    |  23 ++--
 compiler/typecheck/TcErrors.lhs   |   4 +-
 compiler/typecheck/TcEvidence.lhs |  42 +++++--
 compiler/typecheck/TcExpr.lhs     |   8 +-
 compiler/typecheck/TcHsSyn.lhs    |   5 +
 compiler/typecheck/TcHsType.lhs   |  41 ++++---
 compiler/typecheck/TcInstDcls.lhs |   6 +-
 compiler/typecheck/TcPat.lhs      |   8 +-
 compiler/typecheck/TcRnTypes.lhs  |   8 --
 compiler/typecheck/TcType.lhs     |  56 +++++++---
 compiler/typecheck/TcUnify.lhs    | 223 +++++++++++++++++++++++++++++---------
 compiler/typecheck/TcValidity.lhs |  14 +--
 15 files changed, 312 insertions(+), 150 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 b6855422fd532e5988fc98764c5cc47acbefbfb8


More information about the ghc-commits mailing list