+import TcMType ( zonkTcTyVarsAndFV )
+import TcType ( Type, ThetaType, TcKind, TcTyVar, TcTyVarSet,
+ tyVarsOfTypes, tcSplitDFunTy,
+ getDFunTyKey, tcTyConAppTyCon
+ )
+import Id ( isDataConWrapId_maybe )
+import Var ( TyVar, Id, idType )
+import VarSet
+import DataCon ( DataCon )
+import TyCon ( TyCon )
+import Class ( Class, ClassOpItem )
+import Name ( Name, NamedThing(..),
+ getSrcLoc, mkLocalName, isLocalName, nameIsLocalOrFrom
+ )
+import NameEnv ( NameEnv, lookupNameEnv, nameEnvElts, elemNameEnv,
+ extendNameEnvList, emptyNameEnv, plusNameEnv )
+import OccName ( mkDFunOcc, occNameString )
+import HscTypes ( DFunId,
+ PackageTypeEnv, TypeEnv,
+ extendTypeEnvList, extendTypeEnvWithIds,
+ typeEnvTyCons, typeEnvClasses, typeEnvIds,
+ HomeSymbolTable
+ )
+import Module ( Module )
+import InstEnv ( InstEnv, emptyInstEnv )
+import HscTypes ( lookupType, TyThing(..) )
+import Util ( zipEqual )
+import SrcLoc ( SrcLoc )
+import Outputable
+
+import IOExts ( newIORef )
+\end{code}
+
+%************************************************************************
+%* *
+\subsection{TcEnv}
+%* *
+%************************************************************************
+
+\begin{code}
+type TcId = Id -- Type may be a TcType
+type TcIdSet = IdSet
+
+data TcEnv
+ = TcEnv {
+ tcGST :: Name -> Maybe TyThing, -- The type environment at the moment we began this compilation
+
+ tcInsts :: InstEnv, -- All instances (both imported and in this module)
+
+ tcGEnv :: TypeEnv, -- The global type environment we've accumulated while
+ {- NameEnv TyThing-} -- compiling this module:
+ -- types and classes (both imported and local)
+ -- imported Ids
+ -- (Ids defined in this module start in the local envt,
+ -- though they move to the global envt during zonking)
+
+ tcLEnv :: NameEnv TcTyThing, -- The local type environment: Ids and TyVars
+ -- defined in this module
+
+ tcTyVars :: TcRef TcTyVarSet -- The "global tyvars"
+ -- Namely, the in-scope TyVars bound in tcLEnv, plus the tyvars
+ -- mentioned in the types of Ids bound in tcLEnv
+ -- Why mutable? see notes with tcGetGlobalTyVars
+ }