TcLclEnv Refactor
The overall goal of this refactoring is to reduce the dependency footprint of the parser and syntax tree. Good reasons include:
- Better module graph parallelisability
- Make it easier to migrate error messages without introducing module loops
- Philosophically, there's not reason for the AST to depend on half the compiler.
One of the key edges which added this dependency was
GHC.Hs.Expr -> GHC.Tc.Types (TcLclEnv)
As this in turn depending on TcM which depends on HscEnv and so on.
Therefore the goal of this patch is to move TcLclEnv
out of
GHC.Tc.Types
so that GHC.Hs.Expr
can import TcLclEnv without
incurring a huge dependency chain.
The changes in this patch are:
-
Move TcLclEnv from GHC.Tc.Types to GHC.Tc.Types.LclEnv
-
Create new smaller modules for the types used in TcLclEnv New Modules:
- GHC.Tc.Types.ErrCtxt
- GHC.Tc.Types.BasicTypes
- GHC.Tc.Types.TH
- GHC.Tc.Types.LclEnv
- GHC.Tc.Types.CtLocEnv
- GHC.Tc.Errors.Types.PromotionErr
Removed Boot File:
- # SOURCE # GHC.Tc.Types
-
Introduce TcLclCtxt, the part of the TcLclEnv which doesn't participate in restoreLclEnv.
-
Replace TcLclEnv in CtLoc with specific CtLocEnv which is defined in GHC.Tc.Types.CtLocEnv. Use CtLocEnv in Implic and CtLoc to record the location of the implication and constraint.
By splitting up TcLclEnv from GHC.Tc.Types we allow GHC.Hs.Expr to no longer depend on the TcM monad and all that entails.