From 9882db62761ba4664bd918fd362a32f00e73fd72 Mon Sep 17 00:00:00 2001
From: Richard Eisenberg <rae@richarde.dev>
Date: Thu, 17 Feb 2022 21:19:36 +0000
Subject: [PATCH] Flip some bits (directions of coercions in rewriting)

---
 compiler/GHC/Tc/Solver/Rewrite.hs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/compiler/GHC/Tc/Solver/Rewrite.hs b/compiler/GHC/Tc/Solver/Rewrite.hs
index 5f8d0886ae97..c83d5d3ad249 100644
--- a/compiler/GHC/Tc/Solver/Rewrite.hs
+++ b/compiler/GHC/Tc/Solver/Rewrite.hs
@@ -551,20 +551,20 @@ rewrite_one (FunTy { ft_af = vis, ft_mult = mult, ft_arg = ty1, ft_res = ty2 })
                        (rewrite_one res_rep)
        ; role <- getRole
 
-       ; let arg_rep_co = snd arg_rep_redn
+       ; let arg_rep_co = mkSymCo (snd arg_rep_redn)
                 -- :: arg_rep ~ arg_rep_xi
              arg_ki_co  = mkTyConAppCo Nominal tYPETyCon [arg_rep_co]
                 -- :: TYPE arg_rep ~ TYPE arg_rep_xi
              casted_arg_redn =
                  ( mkCastTy arg_xi arg_ki_co
-                 , mkCoherenceRightCo role arg_xi arg_ki_co arg_co
+                 , mkCoherenceLeftCo role arg_xi arg_ki_co arg_co
                  )
                 -- :: ty1 ~> arg_xi |> arg_ki_co
 
-             res_ki_co  = mkTyConAppCo Nominal tYPETyCon [snd res_rep_redn]
+             res_ki_co  = mkTyConAppCo Nominal tYPETyCon [mkSymCo $ snd res_rep_redn]
              casted_res_redn =
                 ( mkCastTy res_xi res_ki_co
-                , mkCoherenceRightCo role res_xi res_ki_co res_co
+                , mkCoherenceLeftCo role res_xi res_ki_co res_co
                 )
 
           -- We must rewrite the representations, because that's what would
-- 
GitLab