summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-02-17 12:36:42 -0500
committerBen Gamari <ben@smart-cactus.org>2022-02-22 14:49:16 -0500
commit333dc7dd3faa1c335e59642f7ad9889b58f29c88 (patch)
tree5c6ef20e4dcddfe327d952eca11527afc5e8ca8b
parent9882db62761ba4664bd918fd362a32f00e73fd72 (diff)
downloadhaskell-333dc7dd3faa1c335e59642f7ad9889b58f29c88.tar.gz
Introduce checkReflexiveMCo
A partial backport of 299b7436d140a5f43ce75a2a1d022572f23fb3f9.
-rw-r--r--compiler/GHC/Core/Coercion.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/GHC/Core/Coercion.hs b/compiler/GHC/Core/Coercion.hs
index c1fa975320..2ee2bca210 100644
--- a/compiler/GHC/Core/Coercion.hs
+++ b/compiler/GHC/Core/Coercion.hs
@@ -72,7 +72,7 @@ module GHC.Core.Coercion (
isReflCoVar_maybe, isGReflMCo, mkGReflLeftMCo, mkGReflRightMCo,
mkCoherenceRightMCo,
- coToMCo, mkTransMCo, mkTransMCoL, mkCastTyMCo, mkSymMCo, isReflMCo,
+ coToMCo, mkTransMCo, mkTransMCoL, mkCastTyMCo, mkSymMCo, isReflMCo, checkReflexiveMCo,
-- ** Coercion variables
mkCoVar, isCoVar, coVarName, setCoVarName, setCoVarUnique,
@@ -311,6 +311,11 @@ coToMCo :: Coercion -> MCoercion
coToMCo co | isReflCo co = MRefl
| otherwise = MCo co
+checkReflexiveMCo :: MCoercion -> MCoercion
+checkReflexiveMCo MRefl = MRefl
+checkReflexiveMCo (MCo co) | isReflexiveCo co = MRefl
+ | otherwise = MCo co
+
-- | Tests if this MCoercion is obviously generalized reflexive
-- Guaranteed to work very quickly.
isGReflMCo :: MCoercion -> Bool