+tcLookupTy :: Name -> NF_TcM s (TcKind, Maybe Arity, TcTyThing)
+tcLookupTy name
+ = tcGetEnv `thenNF_Tc` \ (TcEnv ue te ve gtvs) ->
+ case lookupUFM te name of {
+ Just thing -> returnNF_Tc thing ;
+ Nothing ->
+
+ case maybeWiredInTyConName name of
+ Just tc -> returnNF_Tc (kindToTcKind (tyConKind tc), maybe_arity, ATyCon tc)
+ where
+ maybe_arity | isSynTyCon tc = Just (tyConArity tc)
+ | otherwise = Nothing
+
+ Nothing -> -- This can happen if an interface-file
+ -- unfolding is screwed up
+ failWithTc (tyNameOutOfScope name)
+ }
+
+tcLookupClass :: Name -> NF_TcM s Class
+tcLookupClass name
+ = tcLookupTy name `thenNF_Tc` \ (_, _, AClass clas) ->
+ returnNF_Tc clas
+
+tcLookupTyCon :: Name -> NF_TcM s TyCon
+tcLookupTyCon name
+ = tcLookupTy name `thenNF_Tc` \ (_, _, ATyCon tycon) ->
+ returnNF_Tc tycon
+
+tcLookupClassByKey :: Unique -> NF_TcM s Class
+tcLookupClassByKey key
+ = tcGetEnv `thenNF_Tc` \ (TcEnv ue te ve gtvs) ->
+ case lookupUFM_Directly te key of
+ Just (_, _, AClass cl) -> returnNF_Tc cl
+ other -> pprPanic "tcLookupClassByKey:" (pprUnique10 key)
+
+tcLookupClassByKey_maybe :: Unique -> NF_TcM s (Maybe Class)
+tcLookupClassByKey_maybe key
+ = tcGetEnv `thenNF_Tc` \ (TcEnv ue te ve gtvs) ->
+ case lookupUFM_Directly te key of
+ Just (_, _, AClass cl) -> returnNF_Tc (Just cl)
+ other -> returnNF_Tc Nothing
+
+tcLookupTyConByKey :: Unique -> NF_TcM s TyCon
+tcLookupTyConByKey key
+ = tcGetEnv `thenNF_Tc` \ (TcEnv ue te ve gtvs) ->
+ case lookupUFM_Directly te key of
+ Just (_, _, ATyCon tc) -> returnNF_Tc tc
+ other -> pprPanic "tcLookupTyConByKey:" (pprUnique10 key)
+\end{code}