summaryrefslogtreecommitdiff
path: root/compiler/rename
diff options
context:
space:
mode:
authorRichard Eisenberg <rae@cs.brynmawr.edu>2018-07-14 16:02:13 -0400
committerRichard Eisenberg <rae@cs.brynmawr.edu>2018-08-02 16:38:28 -0400
commitc955a514f033a12f6d0ab0fbacec3e18a5757ab5 (patch)
tree138432de269b813e605fad0e870e9bc205a20c18 /compiler/rename
parentc50574a8e006ff26911f6762187d01210a1dda0f (diff)
downloadhaskell-c955a514f033a12f6d0ab0fbacec3e18a5757ab5.tar.gz
Remove decideKindGeneralisationPlan
TypeInType came with a new function: decideKindGeneralisationPlan. This type-level counterpart to the term-level decideGeneralisationPlan chose whether or not a kind should be generalized. The thinking was that if `let` should not be generalized, then kinds shouldn't either (under the same circumstances around -XMonoLocalBinds). However, this is too conservative -- the situation described in the motivation for "let should be be generalized" does not occur in types. This commit thus removes decideKindGeneralisationPlan, always generalizing. One consequence is that tc_hs_sig_type_and_gen no longer calls solveEqualities, which reports all unsolved constraints, instead relying on the solveLocalEqualities in tcImplicitTKBndrs. An effect of this is that reporing kind errors gets delayed more frequently. This seems to be a net benefit in error reporting; often, alongside a kind error, the type error is now reported (and users might find type errors easier to understand). Some of these errors ended up at the top level, where it was discovered that the GlobalRdrEnv containing the definitions in the local module was not in the TcGblEnv, and thus errors were reported with qualified names unnecessarily. This commit rejiggers some of the logic around captureTopConstraints accordingly. One error message (typecheck/should_fail/T1633) is a regression, mentioning the name of a default method. However, that problem is already reported as #10087, its solution is far from clear, and so I'm not addressing it here. This commit fixes #15141. As it's an internal refactor, there is no concrete test case for it. Along the way, we no longer need the hsib_closed field of HsImplicitBndrs (it was used only in decideKindGeneralisationPlan) and so it's been removed, simplifying the datatype structure. Along the way, I removed code in the validity checker that looks at coercions. This isn't related to this patch, really (though it was, at one point), but it's an improvement, so I kept it. This updates the haddock submodule.
Diffstat (limited to 'compiler/rename')
-rw-r--r--compiler/rename/RnSource.hs5
-rw-r--r--compiler/rename/RnTypes.hs19
2 files changed, 7 insertions, 17 deletions
diff --git a/compiler/rename/RnSource.hs b/compiler/rename/RnSource.hs
index 33e7c7d2b6..beb7c5b705 100644
--- a/compiler/rename/RnSource.hs
+++ b/compiler/rename/RnSource.hs
@@ -765,8 +765,7 @@ rnFamInstEqn doc mb_cls rhs_kvars
all_fvs = fvs `addOneFV` unLoc tycon'
-- type instance => use, hence addOneFV
- ; return (HsIB { hsib_ext = HsIBRn { hsib_vars = all_ibs
- , hsib_closed = True }
+ ; return (HsIB { hsib_ext = all_ibs
, hsib_body
= FamEqn { feqn_ext = noExt
, feqn_tycon = tycon'
@@ -1691,7 +1690,7 @@ rnLDerivStrategy doc mds thing_inside
NewtypeStrategy -> boring_case (L loc NewtypeStrategy)
ViaStrategy via_ty ->
do (via_ty', fvs1) <- rnHsSigType doc via_ty
- let HsIB { hsib_ext = HsIBRn { hsib_vars = via_imp_tvs }
+ let HsIB { hsib_ext = via_imp_tvs
, hsib_body = via_body } = via_ty'
(via_exp_tv_bndrs, _, _) = splitLHsSigmaTy via_body
via_exp_tvs = map hsLTyVarName via_exp_tv_bndrs
diff --git a/compiler/rename/RnTypes.hs b/compiler/rename/RnTypes.hs
index a9e02dc5a5..e5f51660da 100644
--- a/compiler/rename/RnTypes.hs
+++ b/compiler/rename/RnTypes.hs
@@ -127,7 +127,8 @@ rn_hs_sig_wc_type always_bind_free_tvs ctxt
; rnImplicitBndrs bind_free_tvs tv_rdrs $ \ vars ->
do { (wcs, hs_ty', fvs1) <- rnWcBody ctxt nwc_rdrs hs_ty
; let sig_ty' = HsWC { hswc_ext = wcs, hswc_body = ib_ty' }
- ib_ty' = mk_implicit_bndrs vars hs_ty' fvs1
+ ib_ty' = HsIB { hsib_ext = vars
+ , hsib_body = hs_ty' }
; (res, fvs2) <- thing_inside sig_ty'
; return (res, fvs1 `plusFV` fvs2) } }
rn_hs_sig_wc_type _ _ (HsWC _ (XHsImplicitBndrs _)) _
@@ -300,7 +301,9 @@ rnHsSigType ctx (HsIB { hsib_body = hs_ty })
; vars <- extractFilteredRdrTyVarsDups hs_ty
; rnImplicitBndrs (not (isLHsForAllTy hs_ty)) vars $ \ vars ->
do { (body', fvs) <- rnLHsType ctx hs_ty
- ; return ( mk_implicit_bndrs vars body' fvs, fvs ) } }
+ ; return ( HsIB { hsib_ext = vars
+ , hsib_body = body' }
+ , fvs ) } }
rnHsSigType _ (XHsImplicitBndrs _) = panic "rnHsSigType"
rnImplicitBndrs :: Bool -- True <=> bring into scope any free type variables
@@ -367,18 +370,6 @@ rnLHsInstType :: SDoc -> LHsSigType GhcPs -> RnM (LHsSigType GhcRn, FreeVars)
-- Do not try to decompose the inst_ty in case it is malformed
rnLHsInstType doc inst_ty = rnHsSigType (GenericCtx doc) inst_ty
-mk_implicit_bndrs :: [Name] -- implicitly bound
- -> a -- payload
- -> FreeVars -- FreeVars of payload
- -> HsImplicitBndrs GhcRn a
-mk_implicit_bndrs vars body fvs
- = HsIB { hsib_ext = HsIBRn
- { hsib_vars = vars
- , hsib_closed = nameSetAll (not . isTyVarName) (vars `delFVs` fvs) }
- , hsib_body = body }
-
-
-
{- ******************************************************
* *
LHsType and HsType