Refactor the typechecker to use ExpTypes.
authorRichard Eisenberg <eir@cis.upenn.edu>
Thu, 14 Jan 2016 04:29:17 +0000 (23:29 -0500)
committerRichard Eisenberg <eir@cis.upenn.edu>
Wed, 27 Jan 2016 14:33:26 +0000 (09:33 -0500)
commit00cbbab3362578df44851442408a8b91a2a769fa
treec8f79d003510e191adeab0d1b98f20ebde40d914
parent2899aa580d633103fc551e36c977720b94f5b41c
Refactor the typechecker to use ExpTypes.

The idea here is described in [wiki:Typechecker]. Briefly,
this refactor keeps solid track of "synthesis" mode vs
"checking" in GHC's bidirectional type-checking algorithm.
When in synthesis mode, the expected type is just an IORef
to write to.

In addition, this patch does a significant reworking of
RebindableSyntax, allowing much more freedom in the types
of the rebindable operators. For example, we can now have
`negate :: Int -> Bool` and
`(>>=) :: m a -> (forall x. a x -> m b) -> m b`. The magic
is in tcSyntaxOp.

This addresses tickets #11397, #11452, and #11458.

Tests:
  typecheck/should_compile/{RebindHR,RebindNegate,T11397,T11458}
  th/T11452
128 files changed:
compiler/deSugar/Check.hs
compiler/deSugar/Coverage.hs
compiler/deSugar/DsArrows.hs
compiler/deSugar/DsExpr.hs
compiler/deSugar/DsExpr.hs-boot
compiler/deSugar/DsGRHSs.hs
compiler/deSugar/DsListComp.hs
compiler/deSugar/DsMeta.hs
compiler/deSugar/DsUtils.hs
compiler/deSugar/Match.hs
compiler/deSugar/MatchLit.hs
compiler/deSugar/PmExpr.hs
compiler/ghci/RtClosureInspect.hs
compiler/hsSyn/Convert.hs
compiler/hsSyn/HsExpr.hs
compiler/hsSyn/HsExpr.hs-boot
compiler/hsSyn/HsLit.hs
compiler/hsSyn/HsPat.hs
compiler/hsSyn/HsUtils.hs
compiler/hsSyn/PlaceHolder.hs
compiler/parser/Parser.y
compiler/parser/RdrHsSyn.hs
compiler/rename/RnEnv.hs
compiler/rename/RnExpr.hs
compiler/rename/RnPat.hs
compiler/typecheck/Inst.hs
compiler/typecheck/TcArrows.hs
compiler/typecheck/TcBinds.hs
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcEvidence.hs
compiler/typecheck/TcExpr.hs
compiler/typecheck/TcExpr.hs-boot
compiler/typecheck/TcGenDeriv.hs
compiler/typecheck/TcHsSyn.hs
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcInstDcls.hs
compiler/typecheck/TcMType.hs
compiler/typecheck/TcMatches.hs
compiler/typecheck/TcMatches.hs-boot
compiler/typecheck/TcPat.hs
compiler/typecheck/TcPatSyn.hs
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcRnMonad.hs
compiler/typecheck/TcRnTypes.hs
compiler/typecheck/TcRules.hs
compiler/typecheck/TcSplice.hs
compiler/typecheck/TcSplice.hs-boot
compiler/typecheck/TcType.hs
compiler/typecheck/TcUnify.hs
compiler/typecheck/TcValidity.hs
compiler/utils/MonadUtils.hs
testsuite/tests/ado/ado004.stderr
testsuite/tests/annotations/should_fail/annfail10.stderr
testsuite/tests/deSugar/should_run/dsrun017.hs
testsuite/tests/determinism/typecheck/A.hs
testsuite/tests/gadt/gadt-escape1.stderr
testsuite/tests/gadt/gadt13.stderr
testsuite/tests/gadt/gadt7.stderr
testsuite/tests/ghc-api/annotations-literals/parsed.stdout
testsuite/tests/ghci.debugger/scripts/break003.stderr
testsuite/tests/ghci.debugger/scripts/break003.stdout
testsuite/tests/ghci.debugger/scripts/break005.stdout
testsuite/tests/ghci.debugger/scripts/break006.stderr
testsuite/tests/ghci.debugger/scripts/break006.stdout
testsuite/tests/ghci.debugger/scripts/break012.stdout
testsuite/tests/ghci.debugger/scripts/hist001.stdout
testsuite/tests/ghci.debugger/scripts/print022.stdout
testsuite/tests/ghci/scripts/T2182ghci.stderr
testsuite/tests/ghci/scripts/T8959.script
testsuite/tests/ghci/scripts/T8959.stderr
testsuite/tests/ghci/scripts/T8959.stdout
testsuite/tests/indexed-types/should_compile/T3484.hs
testsuite/tests/indexed-types/should_compile/T4120.hs
testsuite/tests/indexed-types/should_compile/T4494.hs
testsuite/tests/indexed-types/should_compile/T9090.hs
testsuite/tests/indexed-types/should_compile/T9316.hs
testsuite/tests/indexed-types/should_fail/T3330a.hs
testsuite/tests/indexed-types/should_fail/T5934.stderr
testsuite/tests/indexed-types/should_fail/T7788.stderr
testsuite/tests/indexed-types/should_fail/T8518.stderr
testsuite/tests/module/mod71.stderr
testsuite/tests/overloadedlists/should_fail/overloadedlistsfail03.hs
testsuite/tests/overloadedlists/should_fail/overloadedlistsfail03.stderr
testsuite/tests/overloadedlists/should_fail/overloadedlistsfail05.hs
testsuite/tests/overloadedlists/should_fail/overloadedlistsfail05.stderr
testsuite/tests/parser/should_compile/read014.stderr
testsuite/tests/parser/should_fail/T7848.stderr
testsuite/tests/partial-sigs/should_compile/T10438.stderr
testsuite/tests/partial-sigs/should_compile/T11192.stderr
testsuite/tests/perf/compiler/all.T
testsuite/tests/polykinds/T7438.stderr
testsuite/tests/rebindable/rebindable6.hs
testsuite/tests/rebindable/rebindable6.stderr
testsuite/tests/rename/should_compile/T3103/GHC/Num.hs [new file with mode: 0644]
testsuite/tests/rename/should_compile/T3103/GHC/Word.hs
testsuite/tests/th/T11452.hs [new file with mode: 0644]
testsuite/tests/th/T11452.stderr [new file with mode: 0644]
testsuite/tests/th/T2222.stderr
testsuite/tests/th/all.T
testsuite/tests/typecheck/should_compile/RebindHR.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/RebindNegate.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T11397.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T11458.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T2683.hs
testsuite/tests/typecheck/should_compile/T7888.hs
testsuite/tests/typecheck/should_compile/all.T
testsuite/tests/typecheck/should_compile/tc141.stderr
testsuite/tests/typecheck/should_compile/tc158.hs
testsuite/tests/typecheck/should_compile/twins.hs
testsuite/tests/typecheck/should_fail/FDsFromGivens2.hs
testsuite/tests/typecheck/should_fail/FDsFromGivens2.stderr
testsuite/tests/typecheck/should_fail/T10619.stderr
testsuite/tests/typecheck/should_fail/T3613.stderr
testsuite/tests/typecheck/should_fail/T5570.stderr
testsuite/tests/typecheck/should_fail/T7453.stderr
testsuite/tests/typecheck/should_fail/T7734.stderr
testsuite/tests/typecheck/should_fail/T8603.stderr
testsuite/tests/typecheck/should_fail/T9109.stderr
testsuite/tests/typecheck/should_fail/VtaFail.stderr
testsuite/tests/typecheck/should_fail/tcfail014.stderr
testsuite/tests/typecheck/should_fail/tcfail016.stderr
testsuite/tests/typecheck/should_fail/tcfail032.stderr
testsuite/tests/typecheck/should_fail/tcfail099.stderr
testsuite/tests/typecheck/should_fail/tcfail104.stderr
testsuite/tests/typecheck/should_fail/tcfail140.stderr
testsuite/tests/typecheck/should_fail/tcfail159.stderr
testsuite/tests/typecheck/should_fail/tcfail181.stderr
utils/ghctags/Main.hs