summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-12-01 15:48:45 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2021-12-30 16:27:22 +0000
commit788c21d1f615d6567e9c42574d3f44f0c72ad801 (patch)
tree4da42adf50b9ac2ba59b2f637eb04664a3e2097f
parent70be4b607d14a3f51ef2628f2f9a02b352b7f6f4 (diff)
downloadhaskell-788c21d1f615d6567e9c42574d3f44f0c72ad801.tar.gz
review from richard
-rw-r--r--compiler/GHC/Core/TyCo/Tidy.hs6
-rw-r--r--compiler/GHC/Tc/Errors.hs9
-rw-r--r--compiler/GHC/Tc/Gen/HsType.hs33
-rw-r--r--compiler/GHC/Tc/Gen/Rule.hs34
-rw-r--r--compiler/GHC/Tc/Gen/Sig.hs2
-rw-r--r--compiler/GHC/Tc/TyCl.hs16
-rw-r--r--compiler/GHC/Tc/TyCl/Class.hs3
-rw-r--r--compiler/GHC/Tc/TyCl/Instance.hs2
-rw-r--r--compiler/GHC/Tc/Types/Origin.hs15
-rw-r--r--compiler/GHC/Tc/Utils/Instantiate.hs6
-rw-r--r--compiler/GHC/Tc/Utils/TcMType.hs1
-rw-r--r--compiler/GHC/Tc/Utils/TcType.hs2
-rw-r--r--compiler/GHC/Tc/Utils/Unify.hs2
-rw-r--r--compiler/GHC/Tc/Utils/Zonk.hs2
-rw-r--r--compiler/GHC/Tc/Validity.hs2
-rw-r--r--compiler/GHC/Types/Var.hs9
16 files changed, 60 insertions, 84 deletions
diff --git a/compiler/GHC/Core/TyCo/Tidy.hs b/compiler/GHC/Core/TyCo/Tidy.hs
index 5756badc81..d9ce6d1043 100644
--- a/compiler/GHC/Core/TyCo/Tidy.hs
+++ b/compiler/GHC/Core/TyCo/Tidy.hs
@@ -27,7 +27,7 @@ import GHC.Types.Var.Env
import GHC.Utils.Misc (strictMap)
import Data.List (mapAccumL)
-import {-# SOURCE #-} GHC.Tc.Utils.TcMType
+import {-# SOURCE #-} GHC.Tc.Utils.TcMType ( tidySkolemInfo )
{-
%************************************************************************
@@ -119,10 +119,8 @@ tidyTyCoVarOcc :: TidyEnv -> TyCoVar -> TyCoVar
tidyTyCoVarOcc env@(_, subst) tv
= case lookupVarEnv subst tv of
Nothing ->
- updateTcTyVarSkolemInfo (upd_details env) $ updateVarType (tidyType env) tv
+ updateTcTyVarSkolemInfo (tidySkolemInfo env) $ updateVarType (tidyType env) tv
Just tv' -> tv'
- where
- upd_details skol_info = tidySkolemInfo skol_info
---------------
diff --git a/compiler/GHC/Tc/Errors.hs b/compiler/GHC/Tc/Errors.hs
index 0327609e94..af3d2aa710 100644
--- a/compiler/GHC/Tc/Errors.hs
+++ b/compiler/GHC/Tc/Errors.hs
@@ -77,7 +77,6 @@ import GHC.Utils.FV ( fvVarList, unionFV )
import GHC.Data.Bag
import GHC.Data.FastString
-import GHC.Utils.Trace (pprTraceUserWarning)
import GHC.Data.List.SetOps ( equivClasses, nubOrdBy )
import GHC.Data.Maybe
import qualified GHC.Data.Strict as Strict
@@ -235,12 +234,10 @@ report_unsolved type_errors expr_holes
-- no sense. Really we should not return those holes at all;
-- for now we just filter them out.
- ; free_tvs' <- mapM zonkTyVarSkolemInfo free_tvs
-
- ; let tidy_env = tidyFreeTyCoVars emptyTidyEnv free_tvs';
+ ; let tidy_env = tidyFreeTyCoVars emptyTidyEnv free_tvs;
; traceTc "reportUnsolved (after zonking):" $
- vcat [ text "Free tyvars:" <+> pprTyVars free_tvs'
+ vcat [ text "Free tyvars:" <+> pprTyVars free_tvs
, text "Tidy env:" <+> ppr tidy_env
, text "Wanted:" <+> ppr wanted ]
@@ -3204,13 +3201,13 @@ getSkolemInfo [] tvs
msg = text "No skolem info - we could not find the origin of the following variables" <+> ppr tvs
$$ text "This should not happen, please report it as a bug following the instructions at:"
$$ text "https://gitlab.haskell.org/ghc/ghc/wikis/report-a-bug"
- -}
getSkolemInfo (implic:implics) tvs
| null tvs_here = getSkolemInfo implics tvs
| otherwise = (ic_info implic, tvs_here) : getSkolemInfo implics tvs_other
where
(tvs_here, tvs_other) = partition (`elem` ic_skols implic) tvs
+ -}
-----------------------
-- relevantBindings looks at the value environment and finds values whose
diff --git a/compiler/GHC/Tc/Gen/HsType.hs b/compiler/GHC/Tc/Gen/HsType.hs
index ae91ec6a88..320db57cbc 100644
--- a/compiler/GHC/Tc/Gen/HsType.hs
+++ b/compiler/GHC/Tc/Gen/HsType.hs
@@ -386,7 +386,7 @@ kcClassSigType :: [LocatedN Name] -> LHsSigType GhcRn -> TcM ()
kcClassSigType names
sig_ty@(L _ (HsSig { sig_bndrs = hs_outer_bndrs, sig_body = hs_ty }))
= addSigCtxt (funsSigCtxt names) sig_ty $
- do { _ <- bindOuterSigTKBndrs_Tv unkSkol hs_outer_bndrs $
+ do { _ <- bindOuterSigTKBndrs_Tv (SigTypeSkol (funsSigCtxt names)) hs_outer_bndrs $
tcLHsType hs_ty liftedTypeKind
; return () }
@@ -1173,7 +1173,7 @@ tc_hs_type mode (HsOpTy _ ty1 (L _ op) ty2) exp_kind
--------- Foralls
tc_hs_type mode (HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind
- = do { (tv_bndrs, ty') <- tcTKTelescope unkSkol mode tele $
+ = do { (tv_bndrs, ty') <- tcTKTelescope mode tele $
tc_lhs_type mode ty exp_kind
-- Pass on the mode from the type, to any wildcards
-- in kind signatures on the forall'd variables
@@ -2462,7 +2462,7 @@ kcInferDeclHeader name flav
-- No standalane kind signature and no CUSK.
-- See note [Required, Specified, and Inferred for types] in GHC.Tc.TyCl
= addTyConFlavCtxt name flav $
- do { let skol_info = unkSkol
+ do { let skol_info = TyConSkol callStack flav name
; (scoped_kvs, (tc_tvs, res_kind))
-- Why bindImplicitTKBndrs_Q_Tv which uses newTyVarTyVar?
-- See Note [Inferring kinds for type declarations] in GHC.Tc.TyCl
@@ -3033,20 +3033,19 @@ expectedKindInCtxt _ = OpenKind
-- HsForAllTelescope
--------------------------------------
-tcTKTelescope :: SkolemInfo
- -> TcTyMode
+tcTKTelescope :: TcTyMode
-> HsForAllTelescope GhcRn
-> TcM a
-> TcM ([TcTyVarBinder], a)
-tcTKTelescope skol_info mode tele thing_inside = case tele of
+tcTKTelescope mode tele thing_inside = case tele of
HsForAllVis { hsf_vis_bndrs = bndrs }
- -> do { (req_tv_bndrs, thing) <- tcExplicitTKBndrsX skol_info skol_mode bndrs thing_inside
+ -> do { (req_tv_bndrs, thing) <- tcExplicitTKBndrsX skol_mode bndrs thing_inside
-- req_tv_bndrs :: [VarBndr TyVar ()],
-- but we want [VarBndr TyVar ArgFlag]
; return (tyVarReqToBinders req_tv_bndrs, thing) }
HsForAllInvis { hsf_invis_bndrs = bndrs }
- -> do { (inv_tv_bndrs, thing) <- tcExplicitTKBndrsX skol_info skol_mode bndrs thing_inside
+ -> do { (inv_tv_bndrs, thing) <- tcExplicitTKBndrsX skol_mode bndrs thing_inside
-- inv_tv_bndrs :: [VarBndr TyVar Specificity],
-- but we want [VarBndr TyVar ArgFlag]
; return (tyVarSpecToBinders inv_tv_bndrs, thing) }
@@ -3154,7 +3153,7 @@ tcOuterTKBndrsX skol_mode skol_info outer_bndrs thing_inside
; return ( HsOuterImplicit{hso_ximplicit = imp_tvs'}
, thing) }
HsOuterExplicit{hso_bndrs = exp_bndrs} ->
- do { (exp_tvs', thing) <- tcExplicitTKBndrsX skol_info skol_mode exp_bndrs thing_inside
+ do { (exp_tvs', thing) <- tcExplicitTKBndrsX skol_mode exp_bndrs thing_inside
; return ( HsOuterExplicit { hso_xexplicit = exp_tvs'
, hso_bndrs = exp_bndrs }
, thing) }
@@ -3164,28 +3163,26 @@ tcOuterTKBndrsX skol_mode skol_info outer_bndrs thing_inside
--------------------------------------
tcExplicitTKBndrs :: OutputableBndrFlag flag 'Renamed
- => SkolemInfo
- -> [LHsTyVarBndr flag GhcRn]
+ => [LHsTyVarBndr flag GhcRn]
-> TcM a
-> TcM ([VarBndr TyVar flag], a)
-tcExplicitTKBndrs skol_info = tcExplicitTKBndrsX skol_info (smVanilla { sm_clone = True })
+tcExplicitTKBndrs = tcExplicitTKBndrsX (smVanilla { sm_clone = True })
tcExplicitTKBndrsX :: OutputableBndrFlag flag 'Renamed
- => SkolemInfo
- -> SkolemMode
+ => SkolemMode
-> [LHsTyVarBndr flag GhcRn]
-> TcM a
-> TcM ([VarBndr TyVar flag], a)
-- Push level, capture constraints,
-- and emit an implication constraint with a ForAllSkol ic_info,
-- so that it is subject to a telescope test.
-tcExplicitTKBndrsX skol_info skol_mode bndrs thing_inside
- = do { (tclvl, wanted, (skol_tvs, res))
+tcExplicitTKBndrsX skol_mode bndrs thing_inside
+ = do { ; let skol_info = ForAllSkol (fsep (map ppr bndrs))
+ ; (tclvl, wanted, (skol_tvs, res))
<- pushLevelAndCaptureConstraints $
bindExplicitTKBndrsX skol_info skol_mode bndrs $
thing_inside
- ; let skol_info = ForAllSkol (fsep (map ppr bndrs))
-- Notice that we use ForAllSkol here, ignoring the enclosing
-- skol_info unlike tc_implicit_tk_bndrs, because the bad-telescope
-- test applies only to ForAllSkol
@@ -3941,7 +3938,7 @@ tcHsPartialSigType ctxt sig_ty
<- solveEqualities "tcHsPartialSigType" $
-- See Note [Failure in local type signatures]
bindNamedWildCardBinders sig_wcs $ \ wcs ->
- bindOuterSigTKBndrs_Tv_M unkSkol mode hs_outer_bndrs $
+ bindOuterSigTKBndrs_Tv_M (SigTypeSkol ctxt) mode hs_outer_bndrs $
do { -- Instantiate the type-class context; but if there
-- is an extra-constraints wildcard, just discard it here
(theta, wcx) <- tcPartialContext mode hs_ctxt
diff --git a/compiler/GHC/Tc/Gen/Rule.hs b/compiler/GHC/Tc/Gen/Rule.hs
index f9b4bba28b..9cbc8f721b 100644
--- a/compiler/GHC/Tc/Gen/Rule.hs
+++ b/compiler/GHC/Tc/Gen/Rule.hs
@@ -122,7 +122,7 @@ tcRule (HsRule { rd_ext = ext
; let skol_info = RuleSkol name
-- Note [Typechecking rules]
; (tc_lvl, stuff) <- pushTcLevelM $
- generateRuleConstraints skol_info ty_bndrs tm_bndrs lhs rhs
+ generateRuleConstraints name ty_bndrs tm_bndrs lhs rhs
; let (id_bndrs, lhs', lhs_wanted
, rhs', rhs_wanted, rule_ty) = stuff
@@ -179,16 +179,16 @@ tcRule (HsRule { rd_ext = ext
, rd_lhs = mkHsDictLet lhs_binds lhs'
, rd_rhs = mkHsDictLet rhs_binds rhs' } }
-generateRuleConstraints :: SkolemInfo
+generateRuleConstraints :: FastString
-> Maybe [LHsTyVarBndr () GhcRn] -> [LRuleBndr GhcRn]
-> LHsExpr GhcRn -> LHsExpr GhcRn
-> TcM ( [TcId]
, LHsExpr GhcTc, WantedConstraints
, LHsExpr GhcTc, WantedConstraints
, TcType )
-generateRuleConstraints skol_info ty_bndrs tm_bndrs lhs rhs
+generateRuleConstraints rule_name ty_bndrs tm_bndrs lhs rhs
= do { ((tv_bndrs, id_bndrs), bndr_wanted) <- captureConstraints $
- tcRuleBndrs skol_info ty_bndrs tm_bndrs
+ tcRuleBndrs rule_name ty_bndrs tm_bndrs
-- bndr_wanted constraints can include wildcard hole
-- constraints, which we should not forget about.
-- It may mention the skolem type variables bound by
@@ -204,38 +204,38 @@ generateRuleConstraints skol_info ty_bndrs tm_bndrs lhs rhs
; return (id_bndrs, lhs', all_lhs_wanted, rhs', rhs_wanted, rule_ty) } }
-- See Note [TcLevel in type checking rules]
-tcRuleBndrs :: SkolemInfo -> Maybe [LHsTyVarBndr () GhcRn] -> [LRuleBndr GhcRn]
+tcRuleBndrs :: FastString -> Maybe [LHsTyVarBndr () GhcRn] -> [LRuleBndr GhcRn]
-> TcM ([TcTyVar], [Id])
-tcRuleBndrs skol_info (Just bndrs) xs
- = do { (tybndrs1,(tys2,tms)) <- bindExplicitTKBndrs_Skol skol_info bndrs $
- tcRuleTmBndrs xs
+tcRuleBndrs rule_name (Just bndrs) xs
+ = do { (tybndrs1,(tys2,tms)) <- bindExplicitTKBndrs_Skol (RuleSkol rule_name) bndrs $
+ tcRuleTmBndrs rule_name xs
; let tys1 = binderVars tybndrs1
; return (tys1 ++ tys2, tms) }
-tcRuleBndrs _ Nothing xs
- = tcRuleTmBndrs xs
+tcRuleBndrs rule_name Nothing xs
+ = tcRuleTmBndrs rule_name xs
-- See Note [TcLevel in type checking rules]
-tcRuleTmBndrs :: [LRuleBndr GhcRn] -> TcM ([TcTyVar],[Id])
-tcRuleTmBndrs [] = return ([],[])
-tcRuleTmBndrs (L _ (RuleBndr _ (L _ name)) : rule_bndrs)
+tcRuleTmBndrs :: FastString -> [LRuleBndr GhcRn] -> TcM ([TcTyVar],[Id])
+tcRuleTmBndrs _ [] = return ([],[])
+tcRuleTmBndrs rule_name (L _ (RuleBndr _ (L _ name)) : rule_bndrs)
= do { ty <- newOpenFlexiTyVarTy
- ; (tyvars, tmvars) <- tcRuleTmBndrs rule_bndrs
+ ; (tyvars, tmvars) <- tcRuleTmBndrs rule_name rule_bndrs
; return (tyvars, mkLocalId name Many ty : tmvars) }
-tcRuleTmBndrs (L _ (RuleBndrSig _ (L _ name) rn_ty) : rule_bndrs)
+tcRuleTmBndrs rule_name (L _ (RuleBndrSig _ (L _ name) rn_ty) : rule_bndrs)
-- e.g x :: a->a
-- The tyvar 'a' is brought into scope first, just as if you'd written
-- a::*, x :: a->a
-- If there's an explicit forall, the renamer would have already reported an
-- error for each out-of-scope type variable used
- = do { let ctxt = RuleSigCtxt name
+ = do { let ctxt = RuleSigCtxt rule_name name
; (_ , tvs, id_ty) <- tcHsPatSigType ctxt HM_Sig rn_ty OpenKind
; let id = mkLocalId name Many id_ty
-- See Note [Typechecking pattern signature binders] in GHC.Tc.Gen.HsType
-- The type variables scope over subsequent bindings; yuk
; (tyvars, tmvars) <- tcExtendNameTyVarEnv tvs $
- tcRuleTmBndrs rule_bndrs
+ tcRuleTmBndrs rule_name rule_bndrs
; return (map snd tvs ++ tyvars, id : tmvars) }
ruleCtxt :: FastString -> SDoc
diff --git a/compiler/GHC/Tc/Gen/Sig.hs b/compiler/GHC/Tc/Gen/Sig.hs
index e9406609b2..01bf4ef4d2 100644
--- a/compiler/GHC/Tc/Gen/Sig.hs
+++ b/compiler/GHC/Tc/Gen/Sig.hs
@@ -411,7 +411,7 @@ tcPatSynSig name sig_ty@(L _ (HsSig{sig_bndrs = hs_outer_bndrs, sig_body = hs_ty
<- pushLevelAndSolveEqualitiesX "tcPatSynSig" $
-- See Note [solveEqualities in tcPatSynSig]
tcOuterTKBndrs skol_info hs_outer_bndrs $
- tcExplicitTKBndrs skol_info ex_hs_tvbndrs $
+ tcExplicitTKBndrs ex_hs_tvbndrs $
do { req <- tcHsContext hs_req
; prov <- tcHsContext hs_prov
; body_ty <- tcHsOpenType hs_body_ty
diff --git a/compiler/GHC/Tc/TyCl.hs b/compiler/GHC/Tc/TyCl.hs
index e2d5b3b562..b61d83e21a 100644
--- a/compiler/GHC/Tc/TyCl.hs
+++ b/compiler/GHC/Tc/TyCl.hs
@@ -1579,7 +1579,7 @@ kcTyClDecl :: TyClDecl GhcRn -> TcTyCon -> TcM ()
kcTyClDecl (DataDecl { tcdLName = (L _ name), tcdDataDefn = defn }) tycon
| HsDataDefn { dd_ctxt = ctxt, dd_cons = cons, dd_ND = new_or_data } <- defn
- = bindTyClTyVars unkSkol name $ \ _ _ _ ->
+ = bindTyClTyVars (TyConSkol callStack DataTypeFlavour name) name $ \ _ _ _ ->
-- NB: binding these tyvars isn't necessary for GADTs, but it does no
-- harm. For GADTs, each data con brings its own tyvars into scope,
-- and the ones from this bindTyClTyVars are either not mentioned or
@@ -1590,14 +1590,14 @@ kcTyClDecl (DataDecl { tcdLName = (L _ name), tcdDataDefn = defn }) tycon
}
kcTyClDecl (SynDecl { tcdLName = L _ name, tcdRhs = rhs }) _tycon
- = bindTyClTyVars unkSkol name $ \ _ _ res_kind ->
+ = bindTyClTyVars (TyConSkol callStack TypeSynonymFlavour name) name $ \ _ _ res_kind ->
discardResult $ tcCheckLHsType rhs (TheKind res_kind)
-- NB: check against the result kind that we allocated
-- in inferInitialKinds.
kcTyClDecl (ClassDecl { tcdLName = L _ name
, tcdCtxt = ctxt, tcdSigs = sigs }) _tycon
- = bindTyClTyVars unkSkol name $ \ _ _ _ ->
+ = bindTyClTyVars (TyConSkol callStack ClassFlavour name) name $ \ _ _ _ ->
do { _ <- tcHsContext ctxt
; mapM_ (wrapLocMA_ kc_sig) sigs }
where
@@ -1681,7 +1681,7 @@ kcConDecl new_or_data
= -- See Note [kcConDecls: kind-checking data type decls]
addErrCtxt (dataConCtxt names) $
discardResult $
- bindOuterSigTKBndrs_Tv unkSkol outer_bndrs $
+ bindOuterSigTKBndrs_Tv (DataConSkol (unLoc (head names))) outer_bndrs $
-- Why "_Tv"? See Note [Using TyVarTvs for kind-checking GADTs]
do { _ <- tcHsContext cxt
; traceTc "kcConDecl:GADT {" (ppr names $$ ppr res_ty)
@@ -2709,7 +2709,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info
, fdResultSig = L _ sig
, fdInjectivityAnn = inj })
| DataFamily <- fam_info
- = bindTyClTyVars unkSkol tc_name $ \ _ binders res_kind -> do
+ = bindTyClTyVars (TyConSkol callStack (DataFamilyFlavour Nothing) tc_name) tc_name $ \ _ binders res_kind -> do
{ traceTc "tcFamDecl1 data family:" (ppr tc_name)
; checkFamFlag tc_name
@@ -2735,7 +2735,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info
; return tycon }
| OpenTypeFamily <- fam_info
- = bindTyClTyVars unkSkol tc_name $ \ _ binders res_kind -> do
+ = bindTyClTyVars (TyConSkol callStack (OpenTypeFamilyFlavour Nothing) tc_name) tc_name $ \ _ binders res_kind -> do
{ traceTc "tcFamDecl1 open type family:" (ppr tc_name)
; checkFamFlag tc_name
; inj' <- tcInjectivity binders inj
@@ -2998,7 +2998,7 @@ kcTyFamInstEqn tc_fam_tc
; checkTyFamInstEqn tc_fam_tc eqn_tc_name hs_pats
; discardResult $
- bindOuterFamEqnTKBndrs_Q_Tv unkSkol outer_bndrs $
+ bindOuterFamEqnTKBndrs_Q_Tv FamInstSkol outer_bndrs $
do { (_fam_app, res_kind) <- tcFamTyPats tc_fam_tc hs_pats
; tcCheckLHsType hs_rhs_ty (TheKind res_kind) }
-- Why "_Tv" here? Consider (#14066)
@@ -3399,7 +3399,7 @@ tcConDecl new_or_data dd_info rep_tycon tc_bndrs res_kind tag_map
; (tclvl, wanted, (exp_tvbndrs, (ctxt, arg_tys, field_lbls, stricts)))
<- pushLevelAndSolveEqualitiesX "tcConDecl:H98" $
- tcExplicitTKBndrs unkSkol explicit_tkv_nms $
+ tcExplicitTKBndrs explicit_tkv_nms $
do { ctxt <- tcHsContext hs_ctxt
; let exp_kind = getArgExpKind new_or_data res_kind
; btys <- tcConH98Args exp_kind hs_args
diff --git a/compiler/GHC/Tc/TyCl/Class.hs b/compiler/GHC/Tc/TyCl/Class.hs
index 50aebeb2b3..675f81e45c 100644
--- a/compiler/GHC/Tc/TyCl/Class.hs
+++ b/compiler/GHC/Tc/TyCl/Class.hs
@@ -216,7 +216,8 @@ tcClassDecl2 class_scoped_tv_env
; let (tyvars, _, _, op_items) = classBigSig clas
prag_fn = mkPragEnv sigs default_binds
sig_fn = mkHsSigFun sigs
- (skol_subst, clas_tyvars) = tcSuperSkolTyVars unkSkol tyvars
+ skol_info = TyConSkol callStack ClassFlavour (getName class_name)
+ (skol_subst, clas_tyvars) = tcSuperSkolTyVars skol_info tyvars
pred = mkClassPred clas (mkTyVarTys clas_tyvars)
scoped_tyvars =
case lookupNameEnv class_scoped_tv_env (unLoc class_name) of
diff --git a/compiler/GHC/Tc/TyCl/Instance.hs b/compiler/GHC/Tc/TyCl/Instance.hs
index 296aa92230..ab40a331c4 100644
--- a/compiler/GHC/Tc/TyCl/Instance.hs
+++ b/compiler/GHC/Tc/TyCl/Instance.hs
@@ -962,7 +962,7 @@ tcDataFamInstHeader mb_clsinfo fam_tc outer_bndrs fixity
= do { sig_kind <- tcLHsKindSig data_ctxt hs_kind
; lvl <- getTcLevel
; let (tvs, inner_kind) = tcSplitForAllInvisTyVars sig_kind
- ; (subst, _tvs') <- tcInstSkolTyVarsAt unkSkol lvl False emptyTCvSubst tvs
+ ; (subst, _tvs') <- tcInstSkolTyVarsAt (SigTypeSkol data_ctxt) lvl False emptyTCvSubst tvs
-- Perhaps surprisingly, we don't need the skolemised tvs themselves
; return (substTy subst inner_kind) }
diff --git a/compiler/GHC/Tc/Types/Origin.hs b/compiler/GHC/Tc/Types/Origin.hs
index 07d67fc0ab..0ea40b1ec5 100644
--- a/compiler/GHC/Tc/Types/Origin.hs
+++ b/compiler/GHC/Tc/Types/Origin.hs
@@ -34,7 +34,6 @@ module GHC.Tc.Types.Origin (
) where
import GHC.Prelude
-import GHC.Utils.Misc (HasCallStack)
import GHC.Tc.Utils.TcType
@@ -94,7 +93,7 @@ data UserTypeCtxt
| PatSigCtxt -- Type sig in pattern
-- eg f (x::t) = ...
-- or (x::t, y) = e
- | RuleSigCtxt Name -- LHS of a RULE forall
+ | RuleSigCtxt FastString Name -- LHS of a RULE forall
-- RULE "foo" forall (x :: a -> a). f (Just x) = ...
| ForSigCtxt Name -- Foreign import or export signature
| DefaultDeclCtxt -- Types in a default declaration
@@ -121,7 +120,6 @@ data UserTypeCtxt
| DataKindCtxt Name -- The kind of a data/newtype (instance)
| TySynKindCtxt Name -- The kind of the RHS of a type synonym
| TyFamResKindCtxt Name -- The result kind of a type family
- deriving (Eq)
-- | Report Redundant Constraints.
data ReportRedundantConstraints
@@ -130,7 +128,6 @@ data ReportRedundantConstraints
-- is the SrcSpan for the constraints
-- E.g. f :: (Eq a, Ord b) => blah
-- The span is for the (Eq a, Ord b)
- deriving (Eq)
reportRedundantConstraints :: ReportRedundantConstraints -> Bool
reportRedundantConstraints NoRRC = False
@@ -157,7 +154,7 @@ redundantConstraintsSpan _ = noSrcSpan
pprUserTypeCtxt :: UserTypeCtxt -> SDoc
pprUserTypeCtxt (FunSigCtxt n _) = text "the type signature for" <+> quotes (ppr n)
pprUserTypeCtxt (InfSigCtxt n) = text "the inferred type for" <+> quotes (ppr n)
-pprUserTypeCtxt (RuleSigCtxt n) = text "the type signature for" <+> quotes (ppr n)
+pprUserTypeCtxt (RuleSigCtxt _ n) = text "the type signature for" <+> quotes (ppr n)
pprUserTypeCtxt (ExprSigCtxt _) = text "an expression type signature"
pprUserTypeCtxt KindSigCtxt = text "a kind signature"
pprUserTypeCtxt (StandaloneKindSigCtxt n) = text "a standalone kind signature for" <+> quotes (ppr n)
@@ -262,12 +259,6 @@ data SkolemInfo
-instance Eq SkolemInfo where
- (SigSkol uc t _) == (SigSkol uc' t' _) = uc == uc' && t `eqType` t'
- (SigTypeSkol uc) == (SigTypeSkol uc') = uc == uc'
- (ForAllSkol {}) == ForAllSkol {} = True
-
-
unkSkol :: HasCallStack => SkolemInfo
unkSkol = UnkSkol callStack
@@ -292,7 +283,7 @@ pprSkolInfo (InferSkol ids) = hang (text "the inferred type" <> plural ids <+>
2 (vcat [ ppr name <+> dcolon <+> ppr ty
| (name,ty) <- ids ])
pprSkolInfo (UnifyForAllSkol ty) = text "the type" <+> ppr ty
-pprSkolInfo (TyConSkol cs flav name) = text "the" <+> ppr flav <+> text "declaration for" <+> quotes (ppr name) $$ prettyCallStackDoc cs
+pprSkolInfo (TyConSkol _cs flav name) = text "the" <+> ppr flav <+> text "declaration for" <+> quotes (ppr name)
pprSkolInfo (DataConSkol name)= text "the data constructor" <+> quotes (ppr name)
pprSkolInfo ReifySkol = text "the type being reified"
diff --git a/compiler/GHC/Tc/Utils/Instantiate.hs b/compiler/GHC/Tc/Utils/Instantiate.hs
index e5237b2744..4ecfcd479a 100644
--- a/compiler/GHC/Tc/Utils/Instantiate.hs
+++ b/compiler/GHC/Tc/Utils/Instantiate.hs
@@ -559,10 +559,8 @@ tcInstSkolTyVarsAt skol_info lvl overlappable subst tvs
= freshenTyCoVarsX new_skol_tv subst tvs
where
new_skol_tv name kind =
- let new_tv = mkTcTyVar name kind sk_details
- sk_details = SkolemTv skol_info' lvl overlappable
- skol_info' = skol_info
- in new_tv
+ let sk_details = SkolemTv skol_info lvl overlappable
+ in mkTcTyVar name kind sk_details
------------------
diff --git a/compiler/GHC/Tc/Utils/TcMType.hs b/compiler/GHC/Tc/Utils/TcMType.hs
index fcccacf999..3cae5f2427 100644
--- a/compiler/GHC/Tc/Utils/TcMType.hs
+++ b/compiler/GHC/Tc/Utils/TcMType.hs
@@ -147,7 +147,6 @@ import GHC.Utils.Trace
import Control.Monad
import GHC.Data.Maybe
import qualified Data.Semigroup as Semi
-import GHC.Tc.Utils.TcType
{-
************************************************************************
diff --git a/compiler/GHC/Tc/Utils/TcType.hs b/compiler/GHC/Tc/Utils/TcType.hs
index bfac22e7f4..fe586b0d6e 100644
--- a/compiler/GHC/Tc/Utils/TcType.hs
+++ b/compiler/GHC/Tc/Utils/TcType.hs
@@ -235,7 +235,7 @@ import Data.List ( mapAccumL )
-- import Data.Functor.Identity( Identity(..) )
import Data.IORef
import Data.List.NonEmpty( NonEmpty(..) )
-import {-# SOURCE #-} GHC.Tc.Types.Origin
+import {-# SOURCE #-} GHC.Tc.Types.Origin ( unkSkol, SkolemInfo )
import Data.Functor.Identity
diff --git a/compiler/GHC/Tc/Utils/Unify.hs b/compiler/GHC/Tc/Utils/Unify.hs
index 6df3b2db8e..36d9de2839 100644
--- a/compiler/GHC/Tc/Utils/Unify.hs
+++ b/compiler/GHC/Tc/Utils/Unify.hs
@@ -864,7 +864,6 @@ tcSkolemise, tcSkolemiseScoped
-- tcSkolemiseScoped and tcSkolemise
tcSkolemiseScoped ctxt expected_ty thing_inside
- -- MP: What to do here?
= do {
; rec { (wrap, tv_prs, given, rho_ty) <- topSkolemise skol_info expected_ty
; let skol_tvs = map snd tv_prs
@@ -883,7 +882,6 @@ tcSkolemise ctxt expected_ty thing_inside
= do { res <- thing_inside expected_ty
; return (idHsWrapper, res) }
| otherwise
- -- MP: Not sure what to do here.
= do {
; rec { (wrap, tv_prs, given, rho_ty) <- topSkolemise skol_info expected_ty
diff --git a/compiler/GHC/Tc/Utils/Zonk.hs b/compiler/GHC/Tc/Utils/Zonk.hs
index 87cfcfaf9f..18c1e36545 100644
--- a/compiler/GHC/Tc/Utils/Zonk.hs
+++ b/compiler/GHC/Tc/Utils/Zonk.hs
@@ -1801,7 +1801,7 @@ zonkTyVarOcc env@(ZonkEnv { ze_flexi = flexi
= case lookupVarEnv tv_env tv of
Nothing -> do
tv' <- updateTyVarKindM (zonkTcTypeToTypeX env) tv
- mkTyVarTy <$> zonkTyVarSkolemInfo tv'
+ return $ mkTyVarTy tv'
Just tv' -> return (mkTyVarTy tv')
zonk_meta ref Flexi
diff --git a/compiler/GHC/Tc/Validity.hs b/compiler/GHC/Tc/Validity.hs
index 9c4b262333..645bfc1afe 100644
--- a/compiler/GHC/Tc/Validity.hs
+++ b/compiler/GHC/Tc/Validity.hs
@@ -362,7 +362,7 @@ checkValidType ctxt ty
= case ctxt of
DefaultDeclCtxt-> MustBeMonoType
PatSigCtxt -> rank0
- RuleSigCtxt _ -> rank1
+ RuleSigCtxt {} -> rank1
TySynCtxt _ -> rank0
ExprSigCtxt {} -> rank1
diff --git a/compiler/GHC/Types/Var.hs b/compiler/GHC/Types/Var.hs
index 2b90cc84a8..1024784589 100644
--- a/compiler/GHC/Types/Var.hs
+++ b/compiler/GHC/Types/Var.hs
@@ -99,7 +99,7 @@ import GHC.Prelude
import {-# SOURCE #-} GHC.Core.TyCo.Rep( Type, Kind, Mult )
import {-# SOURCE #-} GHC.Core.TyCo.Ppr( pprKind )
-import {-# SOURCE #-} GHC.Tc.Utils.TcType( TcTyVarDetails, pprTcTyVarDetails, vanillaSkolemTv, vanillaSkolemTvUnk, updateSkolInfo )
+import {-# SOURCE #-} GHC.Tc.Utils.TcType( TcTyVarDetails, pprTcTyVarDetails, vanillaSkolemTvUnk, updateSkolInfo )
import {-# SOURCE #-} GHC.Types.Id.Info( IdDetails, IdInfo, coVarDetails, isCoVarDetails,
vanillaIdInfo, pprIdDetails )
import {-# SOURCE #-} GHC.Builtin.Types ( manyDataConTy )
@@ -113,11 +113,8 @@ import GHC.Utils.Panic
import GHC.Utils.Panic.Plain
import Data.Data
-import GHC.Utils.Trace
-import GHC.IO.Unsafe
-import GHC.Stack.CCS
-import {-# SOURCE #-} GHC.Tc.Types.Origin
+import {-# SOURCE #-} GHC.Tc.Types.Origin ( SkolemInfo )
{-
************************************************************************
@@ -780,7 +777,7 @@ mkTcTyVar name kind details
tcTyVarDetails :: TyVar -> TcTyVarDetails
-- See Note [TcTyVars and TyVars in the typechecker] in GHC.Tc.Utils.TcType
tcTyVarDetails (TcTyVar { tc_tv_details = details }) = details
-tcTyVarDetails tv@(TyVar {}) = vanillaSkolemTvUnk --pprTrace "tyVar" (text $ show (unsafePerformIO $ whereFrom tv)) $ vanillaSkolemTvUnk
+tcTyVarDetails (TyVar {}) = vanillaSkolemTvUnk --pprTrace "tyVar" (text $ show (unsafePerformIO $ whereFrom tv)) $ vanillaSkolemTvUnk
tcTyVarDetails var = pprPanic "tcTyVarDetails" (ppr var <+> dcolon <+> pprKind (tyVarKind var))
setTcTyVarDetails :: TyVar -> TcTyVarDetails -> TyVar