mkTyConAppCo allocates wastefully
```hs
mkTyConAppCo :: HasDebugCallStack => Role -> TyCon -> [Coercion] -> Coercion
mkTyConAppCo r tc cos
| Just co <- tyConAppFunCo_maybe r tc cos
= co
| ExpandsSyn tv_co_prs rhs_ty leftover_cos <- expandSynTyCon_maybe tc cos
= mkAppCos (liftCoSubst r (mkLiftingContext tv_co_prs) rhs_ty) leftover_cos
----- !!!
-- The allocations I'm talking about happen here
| Just tys_roles <- traverse isReflCo_maybe cos
= mkReflCo r (mkTyConApp tc (map fst tys_roles))
----- !!!
| otherwise = TyConAppCo r tc cos
isReflCo_maybe :: Coercion -> Maybe (Type, Role)
isReflCo_maybe (Refl ty) = Just (ty, Nominal)
isReflCo_maybe (GRefl r ty mco) | isReflKindMCo mco = Just (ty, r)
isReflCo_maybe _ = Nothing
```
There are just so many wasted allocations here. Assuming we take this code path (returning `Refl`), this means that for each argument coercion, the traversal allocates:
- 3 words per `(,)` application
- 3 words per `(:)` application
- 2 words per `Just` application
and the subsequent `map` also allocates two thunks, respectively of the form `fst x` and `map fst xs`, for each argument (due to the definition of `map`), costing 8 extra words.
I discovered this when looking at ticky profiles of GHC compiling `T9872{a,b,c,d}`.
issue