[Git][ghc/ghc][wip/T25647] rename and update note

Patrick (@soulomoon) gitlab at gitlab.haskell.org
Sat Mar 15 06:44:36 UTC 2025


Patrick pushed to branch wip/T25647 at Glasgow Haskell Compiler / GHC


Commits:
e11e2062 by Patrick at 2025-03-15T14:44:24+08:00
rename and update note

- - - - -


2 changed files:

- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Instance.hs


Changes:

=====================================
compiler/GHC/Tc/TyCl.hs
=====================================
@@ -21,7 +21,7 @@ module GHC.Tc.TyCl (
         tcFamTyPats, tcTyFamInstEqn,
         tcAddOpenTyFamInstCtxt, tcMkDataFamInstCtxt, tcAddDataFamInstCtxt,
         unravelFamInstPats, addConsistencyConstraints,
-        checkFamTelescope, tcFamInstLHSBinders
+        checkFamTelescope, quantifyFamInstLHSBinders
     ) where
 
 import GHC.Prelude
@@ -249,9 +249,9 @@ tcTyClGroup (TyClGroup { group_tyclds = tyclds
                  th_bndrs' `plusNameEnv` th_bndrs) }
 
 
-tcFamInstLHSBinders :: TcLevel -> SkolemInfo -> HsOuterFamEqnTyVarBndrs GhcTc -> HsOuterFamEqnTyVarBndrs GhcRn
+quantifyFamInstLHSBinders :: TcLevel -> SkolemInfo -> HsOuterFamEqnTyVarBndrs GhcTc -> HsOuterFamEqnTyVarBndrs GhcRn
   -> [TcTyVar] -> Type -> WantedConstraints -> IOEnv (Env TcGblEnv TcLclEnv) ([TyCoVar], [TcTyVar])
-tcFamInstLHSBinders tclvl skol_info outer_bndrs hs_outer_bndrs wcs lhs_ty wanted = do
+quantifyFamInstLHSBinders tclvl skol_info outer_bndrs hs_outer_bndrs wcs lhs_ty wanted = do
 
        ; let outer_exp_tvs = scopedSort $ explicitOuterTyVars outer_bndrs
        ; let outer_imp_tvs = implicitOuterTyVars outer_bndrs
@@ -267,7 +267,7 @@ tcFamInstLHSBinders tclvl skol_info outer_bndrs hs_outer_bndrs wcs lhs_ty wanted
        ; let final_tvs = scopedSort (qtvs ++ outer_wcs_imp_qtvs ++ outer_exp_tvs)
              -- This scopedSort is important: the qtvs may be /interleaved/ with
              -- the outer_tvs.  See Note [Generalising in tcTyFamInstEqnGuts]
-       ; traceTc "tcFamInstLHSBinders" $
+       ; traceTc "quantifyFamInstLHSBinders" $
          vcat [
                text "lhs_ty:" <+> ppr lhs_ty
               , text "outer_bndrs:" <+> ppr outer_bndrs
@@ -3479,7 +3479,7 @@ tcTyFamInstEqnGuts fam_tc mb_clsinfo outer_hs_bndrs hs_pats hs_rhs_ty
        ; traceTc "tcTyFamInstEqnGuts 0" (ppr outer_bndrs $$ ppr skol_info)
 
       --  -- See Note [Type variables in type families instance decl]
-       ; (final_tvs, qtvs) <- tcFamInstLHSBinders tclvl skol_info outer_bndrs outer_hs_bndrs wcs lhs_ty wanted
+       ; (final_tvs, qtvs) <- quantifyFamInstLHSBinders tclvl skol_info outer_bndrs outer_hs_bndrs wcs lhs_ty wanted
 
        -- See Note [Error on unconstrained meta-variables] in GHC.Tc.Utils.TcMType
        -- Example: typecheck/should_fail/T17301


=====================================
compiler/GHC/Tc/TyCl/Instance.hs
=====================================
@@ -894,11 +894,6 @@ To begin with, let's clarify the terminology:
 * NonStandardTyVars: RuntimeRep, Multiplicity, Levity
 * UTVQ and UTVNQ would not be both present in the same equation. see Note [forall-or-nothing rule]
 
-The old implementation:
-* We are not doing any type variables defaulting for NonStandardTyVars at all.
-  But ITV are defaulted in other places.
-* In rename phase, UTVQ or UTVNQ are collected to binders except WC.
-* In typecheck phase, UTVQ or UTVNQ are treated as skolems, WC and ITV are given TauVars.
 
 Main goal:
 We want ITV defaulting happens in general just as we do in other places(Be it NonStandardTyVars or not).
@@ -932,8 +927,8 @@ Implementation plan:
   * In typecheck phase, collect wildcards in local typecheck env,
   1. emit wildcard type variables to the typecheck env using addWildCards in `tcAnonWildCardOcc`
   2. we use captureWildCards to collect them.
-* ITV: Assign them TauVars, do defaulting and quantification.
-* WC and UTVNQ: Assign them TauVars, but skip defaulting, but quantify just like ITV.
+* ITV: Assign them TauVars, do defaulting(DefaultNonStandardTyVars) and quantification.
+* WC and UTVNQ: Assign them TauVars, but try to skip defaulting(TryNotToDefaultNonStandardTyVars), but quantify just like ITV.
 -}
 
 {-
@@ -1016,7 +1011,7 @@ tcDataFamInstHeader mb_clsinfo skol_info fam_tc hs_outer_bndrs fixity
                            , lhs_applied_kind
                            , res_kind ) }
 
-       ; (final_tvs, qtvs) <- tcFamInstLHSBinders tclvl skol_info outer_bndrs hs_outer_bndrs wcs lhs_ty wanted
+       ; (final_tvs, qtvs) <- quantifyFamInstLHSBinders tclvl skol_info outer_bndrs hs_outer_bndrs wcs lhs_ty wanted
 
        ; (final_tvs, non_user_tvs, lhs_ty, master_res_kind, instance_res_kind, stupid_theta) <-
           liftZonkM $ do



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e11e20628f27698445fbd5f70faa4a9d5b5863a3

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e11e20628f27698445fbd5f70faa4a9d5b5863a3
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20250315/c609d41e/attachment-0001.html>


More information about the ghc-commits mailing list