| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch delivers on #17656, by entirel killing off the complex
floatEqualities mechanism. Previously, floatEqualities would float an
equality out of an implication, so that it could be solved at an outer
level. But now we simply do unification in-place, without floating the
constraint, relying on level numbers to determine untouchability.
There are a number of important new Notes:
* GHC.Tc.Utils.Unify Note [Unification preconditions]
describes the preconditions for unification, including both
skolem-escape and touchability.
* GHC.Tc.Solver.Interact Note [Solve by unification]
describes what we do when we do unify
* GHC.Tc.Solver.Monad Note [The Unification Level Flag]
describes how we control solver iteration under this new scheme
* GHC.Tc.Solver.Monad Note [Tracking Given equalities]
describes how we track when we have Given equalities
* GHC.Tc.Types.Constraint Note [HasGivenEqs]
is a new explanation of the ic_given_eqs field of an implication
A big raft of subtle Notes in Solver, concerning floatEqualities,
disappears.
Main code changes:
* GHC.Tc.Solver.floatEqualities disappears entirely
* GHC.Tc.Solver.Monad: new fields in InertCans, inert_given_eq_lvl
and inert_given_eq, updated by updateGivenEqs
See Note [Tracking Given equalities].
* In exchange for updateGivenEqa, GHC.Tc.Solver.Monad.getHasGivenEqs
is much simpler and more efficient
* I found I could kill of metaTyVarUpdateOK entirely
One test case T14683 showed a 5.1% decrease in compile-time
allocation; and T5631 was down 2.2%. Other changes were small.
Metric Decrease:
T14683
T5631
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Provoked by #18987, this patch adds a missing zonkQuickLook of
app_res_rho in tcApp.
Most of the time this zonk is unnecesary. In fact, I can't think of a
concrete case where it is needed -- hence no test. But even if it
isn't necessary, the reasoning that allows it to be omitted is very
subtle. So I've put it in.
However, adding this zonk does /not/ affect the emitted constraints,
so the reported symptoms for #18987 remain, but harmlessly so, and now
documented in a new Note [Instantiation variables are short lived]
in GHC.Tc.Gen.App.
No change in behaviour, no tests.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There is a zoo of `splitForAll-` functions in `GHC.Core.Type` (as well as
`tcSplitForAll-` functions in `GHC.Tc.Utils.TcType`) that all do very similar
things, but vary in the particular form of type variable that they return. To
make things worse, the names of these functions are often quite misleading.
Some particularly egregious examples:
* `splitForAllTys` returns `TyCoVar`s, but `splitSomeForAllTys` returns
`VarBndr`s.
* `splitSomeForAllTys` returns `VarBndr`s, but `tcSplitSomeForAllTys` returns
`TyVar`s.
* `splitForAllTys` returns `TyCoVar`s, but `splitForAllTysInvis` returns
`InvisTVBinder`s. (This in particular arose in the context of #18939, and
this finally motivated me to bite the bullet and improve the status quo
vis-à-vis how we name these functions.)
In an attempt to bring some sanity to how these functions are named, I have
opted to rename most of these functions en masse to use consistent suffixes
that describe the particular form of type variable that each function returns.
In concrete terms, this amounts to:
* Functions that return a `TyVar` now use the suffix `-TyVar`.
This caused the following functions to be renamed:
* `splitTyVarForAllTys` -> `splitForAllTyVars`
* `splitForAllTy_ty_maybe` -> `splitForAllTyVar_maybe`
* `tcSplitForAllTys` -> `tcSplitForAllTyVars`
* `tcSplitSomeForAllTys` -> `tcSplitSomeForAllTyVars`
* Functions that return a `CoVar` now use the suffix `-CoVar`.
This caused the following functions to be renamed:
* `splitForAllTy_co_maybe` -> `splitForAllCoVar_maybe`
* Functions that return a `TyCoVar` now use the suffix `-TyCoVar`.
This caused the following functions to be renamed:
* `splitForAllTy` -> `splitForAllTyCoVar`
* `splitForAllTys` -> `splitForAllTyCoVars`
* `splitForAllTys'` -> `splitForAllTyCoVars'`
* `splitForAllTy_maybe` -> `splitForAllTyCoVar_maybe`
* Functions that return a `VarBndr` now use the suffix corresponding to the
most relevant type synonym. This caused the following functions to be renamed:
* `splitForAllVarBndrs` -> `splitForAllTyCoVarBinders`
* `splitForAllTysInvis` -> `splitForAllInvisTVBinders`
* `splitForAllTysReq` -> `splitForAllReqTVBinders`
* `splitSomeForAllTys` -> `splitSomeForAllTyCoVarBndrs`
* `tcSplitForAllVarBndrs` -> `tcSplitForAllTyVarBinders`
* `tcSplitForAllTysInvis` -> `tcSplitForAllInvisTVBinders`
* `tcSplitForAllTysReq` -> `tcSplitForAllReqTVBinders`
* `tcSplitForAllTy_maybe` -> `tcSplitForAllTyVarBinder_maybe`
Note that I left the following functions alone:
* Functions that split apart things besides `ForAllTy`s, such as `splitFunTys`
or `splitPiTys`. Thankfully, there are far fewer of these functions than
there are functions that split apart `ForAllTy`s, so there isn't much of a
pressing need to apply the new naming convention elsewhere.
* Functions that split apart `ForAllCo`s in `Coercion`s, such as
`GHC.Core.Coercion.splitForAllCo_maybe`. We could theoretically apply the new
naming convention here, but then we'd have to figure out how to disambiguate
`Type`-splitting functions from `Coercion`-splitting functions. Ultimately,
the `Coercion`-splitting functions aren't used nearly as much as the
`Type`-splitting functions, so I decided to leave the former alone.
This is purely refactoring and should cause no change in behavior.
|
| |
|
|
|
|
| |
[skip ci]
|
| |
|
|
This patch implements Quick Look impredicativity (#18126), sticking
very closely to the design in
A quick look at impredicativity, Serrano et al, ICFP 2020
The main change is that a big chunk of GHC.Tc.Gen.Expr has been
extracted to two new modules
GHC.Tc.Gen.App
GHC.Tc.Gen.Head
which deal with typechecking n-ary applications, and the head of
such applications, respectively. Both contain a good deal of
documentation.
Three other loosely-related changes are in this patch:
* I implemented (partly by accident) points (2,3)) of the accepted GHC
proposal "Clean up printing of foralls", namely
https://github.com/ghc-proposals/ghc-proposals/blob/
master/proposals/0179-printing-foralls.rst
(see #16320).
In particular, see Note [TcRnExprMode] in GHC.Tc.Module
- :type instantiates /inferred/, but not /specified/, quantifiers
- :type +d instantiates /all/ quantifiers
- :type +v is killed off
That completes the implementation of the proposal,
since point (1) was done in
commit df08468113ab46832b7ac0a7311b608d1b418c4d
Author: Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io>
Date: Mon Feb 3 21:17:11 2020 +0100
Always display inferred variables using braces
* HsRecFld (which the renamer introduces for record field selectors),
is now preserved by the typechecker, rather than being rewritten
back to HsVar. This is more uniform, and turned out to be more
convenient in the new scheme of things.
* The GHCi debugger uses a non-standard unification that allows the
unification variables to unify with polytypes. We used to hack
this by using ImpredicativeTypes, but that doesn't work anymore
so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in
GHC.Runtime.Heap.Inspect
Updates haddock submodule.
WARNING: this patch won't validate on its own. It was too
hard to fully disentangle it from the following patch, on
type errors and kind generalisation.
Changes to tests
* Fixes #9730 (test added)
* Fixes #7026 (test added)
* Fixes most of #8808, except function `g2'` which uses a
section (which doesn't play with QL yet -- see #18126)
Test added
* Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted
* Fixes #17332 (test added)
* Fixes #4295
* This patch makes typecheck/should_run/T7861 fail.
But that turns out to be a pre-existing bug: #18467.
So I have just made T7861 into expect_broken(18467)
|