reduce needs for InScopeSets?
eir at cis.upenn.edu
Mon Apr 11 19:53:12 UTC 2016
I now frequently run across ASSERTion failures triggered by the new substitution invariant checks. This is surely a good thing, but it's gotten me thinking about the need for InScopeSets in substitutions at all. It seems to me that the only(?) use of the InScopeSet is in the uniqAway in substTyVarBndr. uniqAway is used here when the kind of a tyvar changes.
Why do we need a new unique when a tyvar's kind changes? Can't we just update the kinds of tyvar occurrences?
One might argue that updating tyvar occurrences' kinds is inefficient. This may be true, but we can tackle that problem head-on by storing a separate TyVarEnv Type that contains tyvar occurrence updates. There's still no need for a new unique.
If we can get rid of InScopeSets in substitutions, that would be a wonderful thing, I think.
Separately, I also see that substTyVar does not currently recur into a tyvar's kind, if the tyvar is not mapped by the substitution. This behavior seems wrong to me, but I guess it's worked thus far.
More information about the ghc-devs