Create a deterministic version of tyVarsOfType
authorBartosz Nitka <niteria@gmail.com>
Sat, 21 Nov 2015 14:57:09 +0000 (15:57 +0100)
committerBen Gamari <ben@smart-cactus.org>
Sat, 21 Nov 2015 16:15:09 +0000 (11:15 -0500)
commit2325bd4e0fad0e5872556c5a78d1a6a1873e7201
tree2aa0eaf21f76b07155ec280095b74e622900e1c3
parent6664ab8356f00ef0b2186f30a0d29a9c0228c045
Create a deterministic version of tyVarsOfType

I've run into situations where I need deterministic `tyVarsOfType` and
this implementation achieves that and also brings an algorithmic
improvement.  Union of two `VarSet`s takes linear time the size of the
sets and in the worst case we can have `n` unions of sets of sizes
`(n-1, 1), (n-2, 1)...` making it quadratic.

One reason why we need deterministic `tyVarsOfType` is in `abstractVars`
in `SetLevels`. When we abstract type variables when floating we want
them to be abstracted in deterministic order.

Test Plan: harbormaster

Reviewers: simonpj, goldfire, austin, hvr, simonmar, bgamari

Reviewed By: simonmar

Subscribers: thomie

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

GHC Trac Issues: #4012
27 files changed:
compiler/basicTypes/IdInfo.hs
compiler/coreSyn/CoreFVs.hs
compiler/coreSyn/CoreSeq.hs
compiler/coreSyn/CoreSubst.hs
compiler/deSugar/DsCCall.hs
compiler/deSugar/DsExpr.hs
compiler/ghc.cabal.in
compiler/ghc.mk
compiler/ghci/ByteCodeGen.hs
compiler/ghci/ByteCodeInstr.hs
compiler/ghci/RtClosureInspect.hs
compiler/simplCore/FloatIn.hs
compiler/simplCore/SetLevels.hs
compiler/specialise/Rules.hs
compiler/typecheck/TcDeriv.hs
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcType.hs
compiler/types/Coercion.hs
compiler/types/TypeRep.hs
compiler/types/Unify.hs
compiler/utils/FV.hs [new file with mode: 0644]
compiler/vectorise/Vectorise/Exp.hs
testsuite/tests/partial-sigs/should_compile/T10403.stderr
testsuite/tests/partial-sigs/should_fail/Trac10045.stderr
testsuite/tests/perf/should_run/T10359 [new file with mode: 0755]
testsuite/tests/polykinds/T9222.stderr