Kill some unnecessary varSetElems
authorBartosz Nitka <niteria@gmail.com>
Fri, 15 Apr 2016 11:46:21 +0000 (04:46 -0700)
committerBartosz Nitka <niteria@gmail.com>
Mon, 25 Jul 2016 14:09:03 +0000 (07:09 -0700)
commit7bfc8c039bd4f4ac82f919e6229660013afdec42
treeecfb0ad209ae3aeafd0f623aaa5e36ff1138da23
parent3ae474d18251d4e9184bf5d6cbce6ac86fdd46c1
Kill some unnecessary varSetElems

When you do `varSetElems (tyCoVarsOfType x)` it's equivalent to
`tyCoVarsOfTypeList x`.

Why? If you look at the implementation:
```
tyCoVarsOfTypeList ty = runFVList $ tyCoVarsOfTypeAcc ty
tyCoVarsOfType ty = runFVSet $ tyCoVarsOfTypeAcc ty
```
they use the same helper function. The helper function returns a
deterministically ordered list and a set. The only difference
between the two is which part of the result they take. It is redundant
to take the set and then immediately convert it to a list.

This helps with determinism and we eventually want to replace the uses
of `varSetElems` with functions that don't leak the values of uniques.
This change gets rid of some instances that are easy to kill.

I chose not to annotate every place where I got rid of `varSetElems`
with a comment about non-determinism, because once we get rid of
`varSetElems` it will not be possible to do the wrong thing.

Test Plan: ./validate

Reviewers: goldfire, austin, simonmar, bgamari, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2115

GHC Trac Issues: #4012

(cherry picked from commit 928d74733975fe4677e2b558d031779f58a0883c)
13 files changed:
compiler/coreSyn/CoreFVs.hs
compiler/coreSyn/CoreLint.hs
compiler/deSugar/Desugar.hs
compiler/deSugar/DsArrows.hs
compiler/deSugar/DsBinds.hs
compiler/main/InteractiveEval.hs
compiler/main/TidyPgm.hs
compiler/specialise/Rules.hs
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcInteract.hs
compiler/typecheck/TcSimplify.hs
compiler/typecheck/TcTyDecls.hs
compiler/typecheck/TcValidity.hs