[Git][ghc/ghc][wip/T22194-flags] 2 commits: Typos and comments
Simon Peyton Jones (@simonpj)
gitlab at gitlab.haskell.org
Wed Mar 29 19:37:24 UTC 2023
Simon Peyton Jones pushed to branch wip/T22194-flags at Glasgow Haskell Compiler / GHC
Commits:
4a359742 by Simon Peyton Jones at 2023-03-29T13:49:02+01:00
Typos and comments
- - - - -
8d947c3c by Simon Peyton Jones at 2023-03-29T20:38:36+01:00
Add a type signature in isAtomicHsExpr
- - - - -
7 changed files:
- compiler/GHC/Core/TyCo/FVs.hs
- compiler/GHC/Core/TyCon.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Tc/Solver/Equality.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Utils/Unify.hs
Changes:
=====================================
compiler/GHC/Core/TyCo/FVs.hs
=====================================
@@ -876,7 +876,7 @@ injectiveVarsOfType look_under_tfs = go
filterByList (flags ++ repeat True) tys
-- Oversaturated arguments to a tycon are
-- always injective, hence the repeat True
- | otherwise -- No injectivity for thsi type family
+ | otherwise -- No injectivity info for this type family
-> emptyFV
| otherwise -- Data type, injective in all positions
=====================================
compiler/GHC/Core/TyCon.hs
=====================================
@@ -838,10 +838,12 @@ data TyConDetails =
-- in the RHS (or is mentioned only under
-- forgetful synonyms)
-- Test is conservative, so True does not guarantee
- -- forgetfulness.
+ -- forgetfulness. False conveys definite information
+ -- (definitely not forgetful); True is always safe.
synIsConcrete :: Bool -- True <= If 'tys' are concrete then the expansion
- -- of (S tys) is concrete
+ -- of (S tys) is definitely concrete
+ -- But False is always safe
}
-- | Represents families (both type and data)
=====================================
compiler/GHC/Core/Type.hs
=====================================
@@ -416,6 +416,10 @@ expandSynTyConApp_maybe tc arg_tys
| Just (tvs, rhs) <- synTyConDefn_maybe tc
, arg_tys `saturates` tyConArity tc
= Just $! (expand_syn tvs rhs arg_tys)
+ -- Why strict application? Because every client of this function will evaluat
+ -- that (expand_syn ...) thunk, so it's more efficient not to build a thunk.
+ -- Mind you, this function is always INLINEd, so the client context is probably
+ -- enough to avoid thunk construction and so the $! is just belt-and-braces.
| otherwise
= Nothing
@@ -2223,9 +2227,17 @@ buildSynTyCon name binders res_kind roles rhs
is_tau = isTauTy rhs
is_fam_free = isFamFreeTy rhs
is_concrete = uniqSetAll isConcreteTyCon rhs_tycons
+ -- NB: is_concrete is allowed to be conservative, returning False
+ -- more often than it could. e.g.
+ -- type S a b = b
+ -- type family F a
+ -- type T a = S (F a) a
+ -- We will mark T as not-concrete, even though (since S ignore its first
+ -- argument, it could be marked concrete.
+
is_forgetful = not (all ((`elemVarSet` rhs_tyvars) . binderVar) binders) ||
uniqSetAny isForgetfulSynTyCon rhs_tycons
- -- NB: This is allowed to be conservative, returning True more often
+ -- NB: is_forgetful is allowed to be conservative, returning True more often
-- than it should. See comments on GHC.Core.TyCon.isForgetfulSynTyCon
rhs_tycons = tyConsOfType rhs
=====================================
compiler/GHC/Hs/Expr.hs
=====================================
@@ -863,12 +863,16 @@ isAtomicHsExpr (XExpr x)
| GhcTc <- ghcPass @p = go_x_tc x
| GhcRn <- ghcPass @p = go_x_rn x
where
+ go_x_tc :: XXExprGhcTc -> Bool
go_x_tc (WrapExpr (HsWrap _ e)) = isAtomicHsExpr e
go_x_tc (ExpansionExpr (HsExpanded a _)) = isAtomicHsExpr a
go_x_tc (ConLikeTc {}) = True
go_x_tc (HsTick {}) = False
go_x_tc (HsBinTick {}) = False
+ go_x_rn :: HsExpansion (HsExpr GhcRn) (HsExpr GhcRn) -> Bool
+ -- Without this signature we would have to infer
+ -- go_x_rn :: forall p2. IsPass p2 => HsExpansion (HsExpr (GhcPass p2)) any -> Bool
go_x_rn (HsExpanded a _) = isAtomicHsExpr a
isAtomicHsExpr _ = False
=====================================
compiler/GHC/Tc/Solver/Equality.hs
=====================================
@@ -2296,7 +2296,7 @@ More details:
[W] alpha ~ Maybe (F alpha, G beta)
We'll end up calling GHC.Tc.Utils.Unify.checkFamApp
* On `F alpha`, which fail and calls the cycle-breaker in TEFA_Break
- * On `G beta`, which suceeds no problem.
+ * On `G beta`, which succeeds no problem.
However, we make no attempt to detect cases like a ~ (F a, F a) and use the
same tyvar to replace F a. The constraint solver will common them up later!
=====================================
compiler/GHC/Tc/Solver/Monad.hs
=====================================
@@ -2064,7 +2064,7 @@ checkTouchableTyVarEq
-> TcTyVar -- A touchable meta-tyvar
-> TcType -- The RHS
-> TcS (PuResult () Reduction)
--- Used for Nominal, Wanted equalities, with a touchble meta-tyvar on LHS
+-- Used for Nominal, Wanted equalities, with a touchable meta-tyvar on LHS
-- If checkTouchableTyVarEq tv ty = PuOK redn cts
-- then we can unify
-- tv := ty |> redn
=====================================
compiler/GHC/Tc/Utils/Unify.hs
=====================================
@@ -2730,6 +2730,8 @@ mapCheck f xs
-- unzipRedns :: [Reduction] -> Reductions
-----------------------------
+-- | Options describing how to deal with a type equality
+-- in the pure unifier. See 'checkTyEqRhs'
data TyEqFlags a
= TEF { tef_foralls :: Bool -- Allow foralls
, tef_lhs :: CanEqLHS -- LHS of the constraint
@@ -2737,7 +2739,9 @@ data TyEqFlags a
, tef_fam_app :: TyEqFamApp a
, tef_occurs :: CheckTyEqProblem } -- Soluble or insoluble occurs check
--- What to do for a type-family application
+-- | What to do when encountering a type-family application while processing
+-- a type equality in the pure unifier.
+--
-- See Note [Family applications in canonical constraints]
data TyEqFamApp a
= TEFA_Fail -- Always fail
@@ -2754,13 +2758,15 @@ data AreUnifying
| NotUnifying -- Not attempting to unify
data LevelCheck
- = LC_None -- Level check not needed: we should never encounter a
- -- tyvar at deeper level than the LHS
+ = LC_None -- Level check not needed: we should never encounter
+ -- a tyvar at deeper level than the LHS
- | LC_Check -- Do a level check against this level; fail if it fails
+ | LC_Check -- Do a level check between the LHS tyvar and the occurrence tyvar
+ -- Fail if the level check fails
- | LC_Promote -- Do a level check against this level; if it fails on a
- -- unification variable, promote it
+ | LC_Promote -- Do a level check between the LHS tyvar and the occurrence tyvar
+ -- If the level check fails, and the occurrence is a unification
+ -- variable, promote it
instance Outputable (TyEqFlags a) where
ppr (TEF { .. }) = text "TEF" <> braces (
@@ -2773,7 +2779,7 @@ instance Outputable (TyEqFlags a) where
instance Outputable (TyEqFamApp a) where
ppr TEFA_Fail = text "TEFA_Fail"
ppr TEFA_Recurse = text "TEFA_Fail"
- ppr (TEFA_Break {}) = text "TEFA_Brefak"
+ ppr (TEFA_Break {}) = text "TEFA_Break"
instance Outputable AreUnifying where
ppr NotUnifying = text "NotUnifying"
@@ -3076,8 +3082,12 @@ checkTyVar (TEF { tef_lhs = lhs, tef_unifying = unifying, tef_occurs = occ_prob
-- Remember, the entire process started with a fully zonked type
Nothing -> check_unif info lvl LC_Promote lhs_tv }
+
check_tv (Unifying info lvl prom) lhs_tv
- = check_unif info lvl prom lhs_tv
+ = -- If prom=LC_Check or LC_None we don't fill any tyvars,
+ -- so no need for the isFilledMetaTyVar check
+ -- Remember, the entire process started with a fully zonked type
+ check_unif info lvl prom lhs_tv
---------------------
-- We are in the Unifying branch of AreUnifing
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/312b39757c5af257985a72d2f29ebed803bc8722...8d947c3c235899bdaa85aa54f34d7ede00bb9443
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/312b39757c5af257985a72d2f29ebed803bc8722...8d947c3c235899bdaa85aa54f34d7ede00bb9443
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/20230329/7221b9b5/attachment-0001.html>
More information about the ghc-commits
mailing list