Replace TcLclEnv in CtLoc with a specific datatype
The TcLclEnv
is used in a CtLoc
for some error reporting but a large part of it isn't used.
It is problematic because it induces an import of GHC.Tc.Types
from where CtLoc
is defined which creates a big module cycle, because TcLclEnv
contains WantedConstraints
which contain Ct
s which contains CtLocs
and so on.
From a module graph perspective this is bad, because having loops like this harms compile time.
From a logic perspective this is bad, because a CtLoc can contain a TcLclEnv which in theory could contain more CtLoc and so on. There is also no reason to presuppose that what is needed in a CtLocEnv is precisely, or a subset of a TcLclEnv
. There could easily be more/different information in the CtLocEnv
which is not needed by a TcLclEnv
.
The solution is to define a separate type CtLocEnv
which contains just what is needed for error reporting and provide a function to create a CtLocEnv
from a TcLclEnv
when it's needed.