Split up TcLclEnv to break module loop between GHC.Tc.Types.Constraint and GHC.Tc.Types
Currently, TcLclEnv
stores a WantedConstraints
, and each constraint Ct
stores a CtLoc
which stores a TcLclEnv
. This means that Ct
and TcLclEnv
are mutually recursive, but it doesn't need to be that way as we only need a subset of TcLclEnv
for Ct
s; I don't think we want this infinite nesting of contexts.
I suggest splitting up TcLclEnv
, e.g.:
data TcLclEnv
= TcLclEnv {
tcl_ctxt :: TcLclCtxt
tcl_lie :: TcRef WantedConstraints,
tcl_errs :: TcRef (Messages TcRnMessage),
tcl_usage :: TcRef UsageEnv,
}
data TcLclCtxt
= TcLclCtxt {
tcl_loc :: RealSrcSpan,
tcl_err_ctxt :: [ErrCtxt],
tcl_in_gen_code :: Bool,
tcl_tclvl :: TcLevel,
tcl_th_ctxt :: ThStage,
tcl_th_bndrs :: ThBindEnv,
tcl_arrow_ctxt :: ArrowCtxt,
tcl_rdr :: LocalRdrEnv,
tcl_env :: TcTypeEnv,
tcl_bndrs :: TcBinderStack,
}
The idea would be to put TcLclCtxt
in its own module, lower down in the module hierarchy. It would be imported by both GHC.Tc.Types
and GHC.Tc.Types.Constraint
, but those latter two modules would no longer need to import each other.