diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2021-11-08 19:11:58 -0500 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2021-11-08 19:14:13 -0500 |
commit | d7865c4e9fa139d5ba7a40211c1de3e30db0c2f5 (patch) | |
tree | 266ffaf0c32c95c5c7f3f5294284defcba228bbe /compiler/GHC/Tc/Gen | |
parent | f8a98fd004769a0a0b700c34aee9df126797aa4b (diff) | |
download | haskell-wip/T20501.tar.gz |
Flesh out Note [The stupid context] and reference itwip/T20501
`Note [The stupid context]` in `GHC.Core.DataCon` talks about stupid contexts
from `DatatypeContexts`, but prior to this commit, it was rather outdated.
This commit spruces it up and references it from places where it is relevant.
Diffstat (limited to 'compiler/GHC/Tc/Gen')
-rw-r--r-- | compiler/GHC/Tc/Gen/Expr.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/Tc/Gen/Head.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Tc/Gen/Pat.hs | 3 |
3 files changed, 7 insertions, 3 deletions
diff --git a/compiler/GHC/Tc/Gen/Expr.hs b/compiler/GHC/Tc/Gen/Expr.hs index c9e9129251..6739e9a375 100644 --- a/compiler/GHC/Tc/Gen/Expr.hs +++ b/compiler/GHC/Tc/Gen/Expr.hs @@ -790,7 +790,8 @@ tcExpr expr@(RecordUpd { rupd_expr = record_expr, rupd_flds = Left rbnds }) res_ -- Typecheck the bindings ; rbinds' <- tcRecordUpd con1 con1_arg_tys' rbinds - -- STEP 6: Deal with the stupid theta + -- STEP 6: Deal with the stupid theta. + -- See Note [The stupid context] in GHC.Core.DataCon. ; let theta' = substThetaUnchecked scrut_subst (conLikeStupidTheta con1) ; instStupidTheta RecordUpdOrigin theta' diff --git a/compiler/GHC/Tc/Gen/Head.hs b/compiler/GHC/Tc/Gen/Head.hs index bfaba5efcc..821b118ded 100644 --- a/compiler/GHC/Tc/Gen/Head.hs +++ b/compiler/GHC/Tc/Gen/Head.hs @@ -905,7 +905,9 @@ being able to reconstruct the exact original program. Note [Instantiating stupid theta] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider a data type with a "stupid theta": +Consider a data type with a "stupid theta" (see +Note [The stupid context] in GHC.Core.DataCon): + data Ord a => T a = MkT (Maybe a) We want to generate an Ord constraint for every use of MkT; but diff --git a/compiler/GHC/Tc/Gen/Pat.hs b/compiler/GHC/Tc/Gen/Pat.hs index a09d77b6f7..a235c43236 100644 --- a/compiler/GHC/Tc/Gen/Pat.hs +++ b/compiler/GHC/Tc/Gen/Pat.hs @@ -1311,7 +1311,8 @@ tcConArg penv (arg_pat, Scaled arg_mult arg_ty) addDataConStupidTheta :: DataCon -> [TcType] -> TcM () -- Instantiate the "stupid theta" of the data con, and throw --- the constraints into the constraint set +-- the constraints into the constraint set. +-- See Note [The stupid context] in GHC.Core.DataCon. addDataConStupidTheta data_con inst_tys | null stupid_theta = return () | otherwise = instStupidTheta origin inst_theta |