[commit: ghc] wip/spj-tc-branch: A collection of type-inference refactorings. (f477756)
git at git.haskell.org
git at git.haskell.org
Tue Sep 20 20:48:32 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/spj-tc-branch
Link : http://ghc.haskell.org/trac/ghc/changeset/f477756baefc1b16549631efa0de56ccbb66bdef/ghc
>---------------------------------------------------------------
commit f477756baefc1b16549631efa0de56ccbb66bdef
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Tue Aug 30 11:00:47 2016 +0100
A collection of type-inference refactorings.
1. Modify TcType.ExpType to make a distinct data type,
InferResult for the Infer case, and consequential
refactoring.
2. Define a new function TcUnify.fillInferResult, to fill in
an InferResult. It uses TcMType.promoteTcType to promote
the type to the level of the InferResult.
See TcMType Note [Promoting a type]
This refactoring is in preparation for an improvement
to typechecking pattern bindings, coming next.
I flirted with an elaborate scheme to give better
higher rank inference, but it was just too complicated.
See TcMType Note [Promotion and higher rank types]
3. Add to InferResult a new field ir_inst :: Bool to say
whether or not the type used to fill in the
InferResult should be deeply instantiated. See
TcUnify Note [Deep instantiation of InferResult].
4. Add a TcLevel to SkolemTvs. This will be useful generally
- it's a fast way to see if the type
variable escapes when floating (not used yet)
- it provides a good consistency check when updating a
unification variable (TcMType.writeMetaTyVarRef, the
level_check_ok check)
I originally had another reason (related to the flirting
in (2), but I left it in because it seems like a step in
the right direction.
5. Reduce and simplify the plethora of uExpType,
tcSubType and related functions in TcUnify. It was
such an opaque mess and it's still not great, but it's
better.
6. Simplify the uo_expected field of TypeEqOrigin. Richard
had generatlised it to a ExpType, but it was almost always
a Check type. Now it's back to being a plain TcType which
is much easier.
7. Improve error messages by refraining from skolemisation when
it's clear that there's an error: see
TcUnify Note [Don't skolemise unnecessarily]
8. Type.isPiTy and isForAllTy seem to be missing a coreView check,
so I added it
All these changes led to quite bit of error message wibbling
>---------------------------------------------------------------
f477756baefc1b16549631efa0de56ccbb66bdef
compiler/ghci/RtClosureInspect.hs | 2 +-
compiler/typecheck/Inst.hs | 4 +-
compiler/typecheck/TcBinds.hs | 68 +---
compiler/typecheck/TcErrors.hs | 6 +-
compiler/typecheck/TcExpr.hs | 24 +-
compiler/typecheck/TcHsSyn.hs | 2 +-
compiler/typecheck/TcHsType.hs | 21 +-
compiler/typecheck/TcInstDcls.hs | 3 +-
compiler/typecheck/TcMType.hs | 324 +++++++++++-----
compiler/typecheck/TcMatches.hs | 19 +-
compiler/typecheck/TcPat.hs | 34 +-
compiler/typecheck/TcPatSyn.hs | 16 +-
compiler/typecheck/TcRnTypes.hs | 2 +-
compiler/typecheck/TcType.hs | 75 ++--
compiler/typecheck/TcUnify.hs | 407 +++++++++++----------
compiler/typecheck/TcValidity.hs | 2 +-
compiler/types/Type.hs | 2 +
compiler/vectorise/Vectorise/Generic/PData.hs | 2 +-
testsuite/tests/ado/ado004.stderr | 4 +-
.../tests/annotations/should_fail/annfail10.stderr | 12 +-
testsuite/tests/driver/T2182.stderr | 32 +-
testsuite/tests/gadt/gadt-escape1.stderr | 16 +-
testsuite/tests/gadt/gadt13.stderr | 10 +-
testsuite/tests/gadt/gadt7.stderr | 18 +-
.../tests/ghci.debugger/scripts/break012.stdout | 8 +-
.../tests/ghci.debugger/scripts/print022.stdout | 4 +-
testsuite/tests/ghci/scripts/T11524a.stdout | 4 +-
testsuite/tests/ghci/scripts/T2182ghci.stderr | 10 +-
.../tests/indexed-types/should_fail/T12386.hs | 9 +
.../tests/indexed-types/should_fail/T12386.stderr | 7 +
.../tests/indexed-types/should_fail/T7354.stderr | 8 +-
.../tests/parser/should_compile/read014.stderr | 2 +-
testsuite/tests/parser/should_fail/T7848.stderr | 3 -
.../tests/parser/should_fail/readFail003.stderr | 4 +-
.../partial-sigs/should_compile/T10438.stderr | 14 +-
.../tests/patsyn/should_compile/T11213.stderr | 2 +-
testsuite/tests/patsyn/should_fail/mono.stderr | 4 +-
testsuite/tests/perf/compiler/stdout | 29 ++
testsuite/tests/polykinds/T7438.stderr | 16 +-
testsuite/tests/rebindable/rebindable6.stderr | 12 +-
testsuite/tests/roles/should_compile/T8958.stderr | 5 +-
testsuite/tests/th/T11452.stderr | 2 +-
testsuite/tests/th/T2222.stderr | 2 +-
.../typecheck/should_compile/ExPatFail.stderr | 4 +-
.../should_compile/T12427.stderr} | 0
.../tests/typecheck/should_compile/T12427a.stderr | 33 ++
.../tests/typecheck/should_compile/tc141.stderr | 6 +-
.../tests/typecheck/should_fail/T10495.stderr | 10 +-
.../tests/typecheck/should_fail/T10619.stderr | 18 +-
.../tests/typecheck/should_fail/T12177.stderr | 19 +-
testsuite/tests/typecheck/should_fail/T3102.hs | 6 +-
testsuite/tests/typecheck/should_fail/T3102.stderr | 12 -
testsuite/tests/typecheck/should_fail/T7453.stderr | 50 +--
testsuite/tests/typecheck/should_fail/T7734.stderr | 12 +-
testsuite/tests/typecheck/should_fail/T8428.stderr | 5 +-
testsuite/tests/typecheck/should_fail/T9109.stderr | 10 +-
testsuite/tests/typecheck/should_fail/T9318.stderr | 12 +-
.../tests/typecheck/should_fail/VtaFail.stderr | 2 +-
testsuite/tests/typecheck/should_fail/all.T | 2 +-
.../tests/typecheck/should_fail/tcfail002.stderr | 6 +-
.../tests/typecheck/should_fail/tcfail004.stderr | 6 +-
.../tests/typecheck/should_fail/tcfail005.stderr | 6 +-
.../tests/typecheck/should_fail/tcfail013.stderr | 2 +-
.../tests/typecheck/should_fail/tcfail014.stderr | 6 +-
.../tests/typecheck/should_fail/tcfail018.stderr | 2 +-
.../tests/typecheck/should_fail/tcfail032.stderr | 6 +-
.../tests/typecheck/should_fail/tcfail099.stderr | 6 +-
.../tests/typecheck/should_fail/tcfail104.stderr | 10 +-
.../tests/typecheck/should_fail/tcfail140.stderr | 4 +-
.../tests/typecheck/should_fail/tcfail181.stderr | 2 +-
70 files changed, 848 insertions(+), 659 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 f477756baefc1b16549631efa0de56ccbb66bdef
More information about the ghc-commits
mailing list