-lookup_global :: TcGblEnv -> Name -> Maybe TyThing
- -- Try the global envt and then the global symbol table
-lookup_global env name
- = lookupNameEnv (tcg_type_env env) name
- `seqMaybe`
- tcg_ist env name
-
-tcLookupGlobal_maybe :: Name -> TcRn m (Maybe TyThing)
-tcLookupGlobal_maybe name
- = getGblEnv `thenM` \ env ->
- returnM (lookup_global env name)
-\end{code}
-
-A variety of global lookups, when we know what we are looking for.
-
-\begin{code}
-tcLookupGlobal :: Name -> TcM TyThing
-tcLookupGlobal name
- = tcLookupGlobal_maybe name `thenM` \ maybe_thing ->
- case maybe_thing of
- Just thing -> returnM thing
- other -> notFound "tcLookupGlobal" name
-
-tcLookupGlobalId :: Name -> TcM Id
-tcLookupGlobalId name
- = tcLookupGlobal_maybe name `thenM` \ maybe_thing ->
- case maybe_thing of
- Just (AnId id) -> returnM id
- other -> notFound "tcLookupGlobal" name
-
-tcLookupDataCon :: Name -> TcM DataCon
-tcLookupDataCon con_name
- = tcLookupGlobalId con_name `thenM` \ con_id ->
- case isDataConWrapId_maybe con_id of
- Just data_con -> returnM data_con
- Nothing -> failWithTc (badCon con_id)
-
-tcLookupClass :: Name -> TcM Class
-tcLookupClass name
- = tcLookupGlobal_maybe name `thenM` \ maybe_clas ->
- case maybe_clas of
- Just (AClass clas) -> returnM clas
- other -> notFound "tcLookupClass" name
-
-tcLookupTyCon :: Name -> TcM TyCon
-tcLookupTyCon name
- = tcLookupGlobal_maybe name `thenM` \ maybe_tc ->
- case maybe_tc of
- Just (ATyCon tc) -> returnM tc
- other -> notFound "tcLookupTyCon" name
-
-
-getInGlobalScope :: TcRn m (Name -> Bool)
-getInGlobalScope = do { gbl_env <- getGblEnv ;
- return (\n -> isJust (lookup_global gbl_env n)) }
+tcExtendRecEnv :: [(Name,TyThing)] -> TcM r -> TcM r
+-- Extend the global environments for the type/class knot tying game
+tcExtendRecEnv gbl_stuff thing_inside
+ = updGblEnv upd thing_inside
+ where
+ upd env = env { tcg_type_env = extend (tcg_type_env env) }
+ extend env = extendNameEnvList env gbl_stuff