Note [Rewriting synonyms]
Not expanding synonyms aggressively improves error messages, and
keeps types smaller. But we need to take care.
Suppose
type Syn a = Int
type instance F Bool = Syn (F Bool)
[G] F Bool ~ Syn (F Bool)
If we don't expand the synonym, we'll get a spurious occurs-check
failure. This is normally what occCheckExpand takes care of, but
the LHS is a type family application, and occCheckExpand (already
complex enough as it is) does not know how to expand to avoid
a type family application.
In addition, expanding the forgetful synonym like this
will generally yield a *smaller* type. To wit, if we spot
S ( ... F tys ... ), where S is forgetful, we don't want to bother
doing hard work simplifying (F tys). We thus expand forgetful
synonyms, but not others.
isForgetfulSynTyCon returns True more often than it needs to, so
we err on the side of more expansion.
We also, of course, must expand type synonyms that mention type families,
so those families can get reduced.
************************************************************************
* *
Rewriting a type-family application
* *
************************************************************************ References 0
This Note does not link to any other.
Referenced by 3
- GHC.Core.Type call site
- Rewriting GHC.Tc.Solver.Rewrite
- GHC.Tc.Solver.Rewrite call site