SpecConstr: Instead of filtering out in scope free variables after the fact filter the free variables as we construct the patterns.
Currently in SpecConstr we:
- Transform the arguments into potential call patterns
- Gather the free variables of all call patterns to construct the set of potential arguments for the specialized version
- Remove any argument from the set which is in scope.
It seems to me we could just pass the in scope set to argToPat and have it do this work.
That is instead of returning (Bool, CoreArg)
argToPat would return (Bool, CoreArg, [Var])
.
The list of vars is the list of variables not in scope in the patterns. And we save ourselfs the trouble of computing the free variables of the patterns.
Likely not a huge win so not planing to do this right now. So if anyone feels like tackling this feel free.