Strict TTG extension fields
Currently, the TTG extension fields are not strict:
data HsType pass
= ...
| HsTyVar (XTyVar pass) PromotionFlag (LIdP pass)
| HsAppTy (XAppTy pass) (LHsType pass) (LHsType pass)
| ...
But they very well could be:
data HsType pass
= ...
| HsTyVar !(XTyVar pass) PromotionFlag (LIdP pass)
| HsAppTy !(XAppTy pass) (LHsType pass) (LHsType pass)
| ...
This would allow one to "exclude" certain constructors by using Void
:
type instance XTyVar GhcTc = Void
And then the pattern match exhaustiveness checker would see that HsTyVar
is an impossible case, without an explicit call to absurd
. We already do that for sum extension fields, but for some reason not for all of them.
It's easy to recover laziness by using a wrapper, at the cost of a pointer indirection:
data Box a = Box a
I propose to make all extension fields throughout the compiler strict. Thoughts?