summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core
diff options
context:
space:
mode:
authorCarrieMY <carrie.xmy@gmail.com>2022-05-25 16:43:03 +0200
committersheaf <sam.derbyshire@gmail.com>2022-05-25 16:43:03 +0200
commite74fc066cb33e5b7ae0d37cedb30230c597ef1ce (patch)
treecc17cbbe235ada53bdac93e06cbfe4ca632ffa4a /compiler/GHC/Core
parent2ff18e390b119c611b3dd429b76cfcbf36ef9545 (diff)
downloadhaskell-wip/T18802.tar.gz
Desugar RecordUpd in `tcExpr`wip/T18802
This patch typechecks record updates by desugaring them inside the typechecker using the HsExpansion mechanism, and then typechecking this desugared result. Example: data T p q = T1 { x :: Int, y :: Bool, z :: Char } | T2 { v :: Char } | T3 { x :: Int } | T4 { p :: Float, y :: Bool, x :: Int } | T5 The record update `e { x=e1, y=e2 }` desugars as follows e { x=e1, y=e2 } ===> let { x' = e1; y' = e2 } in case e of T1 _ _ z -> T1 x' y' z T4 p _ _ -> T4 p y' x' The desugared expression is put into an HsExpansion, and we typecheck that. The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr. Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289 Updates haddock submodule
Diffstat (limited to 'compiler/GHC/Core')
-rw-r--r--compiler/GHC/Core/Coercion.hs24
1 files changed, 0 insertions, 24 deletions
diff --git a/compiler/GHC/Core/Coercion.hs b/compiler/GHC/Core/Coercion.hs
index 0999c5d7d1..1416e231a9 100644
--- a/compiler/GHC/Core/Coercion.hs
+++ b/compiler/GHC/Core/Coercion.hs
@@ -44,7 +44,6 @@ module GHC.Core.Coercion (
mkGReflRightCo, mkGReflLeftCo, mkCoherenceLeftCo, mkCoherenceRightCo,
mkKindCo,
castCoercionKind, castCoercionKind1, castCoercionKind2,
- mkFamilyTyConAppCo,
mkHeteroCoercionType,
mkPrimEqPred, mkReprPrimEqPred, mkPrimEqPredRole,
@@ -1614,29 +1613,6 @@ castCoercionKind g h1 h2
where
(Pair t1 t2, r) = coercionKindRole g
-mkFamilyTyConAppCo :: TyCon -> [CoercionN] -> CoercionN
--- ^ Given a family instance 'TyCon' and its arg 'Coercion's, return the
--- corresponding family 'Coercion'. E.g:
---
--- > data family T a
--- > data instance T (Maybe b) = MkT b
---
--- Where the instance 'TyCon' is :RTL, so:
---
--- > mkFamilyTyConAppCo :RTL (co :: a ~# Int) = T (Maybe a) ~# T (Maybe Int)
---
--- cf. 'mkFamilyTyConApp'
-mkFamilyTyConAppCo tc cos
- | Just (fam_tc, fam_tys) <- tyConFamInst_maybe tc
- , let tvs = tyConTyVars tc
- fam_cos = assertPpr (tvs `equalLength` cos) (ppr tc <+> ppr cos) $
- map (liftCoSubstWith Nominal tvs cos) fam_tys
- = mkTyConAppCo Nominal fam_tc fam_cos
- | otherwise
- = mkTyConAppCo Nominal tc cos
-
--- See Note [Newtype coercions] in GHC.Core.TyCon
-
mkPiCos :: Role -> [Var] -> Coercion -> Coercion
mkPiCos r vs co = foldr (mkPiCo r) co vs