diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-07-13 13:23:26 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-07-22 14:23:27 -0400 |
commit | b2d5c41ba3376081c43c8874f8bbb4d9f3c03a7d (patch) | |
tree | 4205cd893d60dd5366626e0c17235457a607b438 | |
parent | 4854a3490518760405f04826df1768b5a7b96da2 (diff) | |
download | haskell-wip/optimize-mksubco.tar.gz |
Optimize mkSubCo on basis of idempotencywip/optimize-mksubco
`SubCo (SubCo co)` is equivalent to `SubCo co`. Consequently there is no
reason to nest `SubCo`s. I don't know of any case where we might
generate such a nested construction but this seems like a worthwhile
case to handle regardless.
-rw-r--r-- | compiler/types/Coercion.hs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/compiler/types/Coercion.hs b/compiler/types/Coercion.hs index 81331e0b8e..a95d12c934 100644 --- a/compiler/types/Coercion.hs +++ b/compiler/types/Coercion.hs @@ -1198,6 +1198,7 @@ mkSubCo (FunCo Nominal arg res) = FunCo Representational (downgradeRole Representational Nominal arg) (downgradeRole Representational Nominal res) +mkSubCo co@(SubCo _) = co mkSubCo co = ASSERT2( coercionRole co == Nominal, ppr co <+> ppr (coercionRole co) ) SubCo co |