tcLookupGlobal_maybe, tcLookupGlobal,
-- Local environment
- tcExtendKindEnv,
+ tcExtendKindEnv, tcLookupLocalIds,
tcExtendTyVarEnv, tcExtendTyVarEnvForMeths,
- tcExtendLocalValEnv, tcLookup,
+ tcExtendLocalValEnv, tcLookup, tcLookup_maybe,
-- Global type variables
tcGetGlobalTyVars, tcExtendGlobalTyVars,
-- Random useful things
- RecTcEnv, tcAddImportedIdInfo, tcLookupRecId, tcLookupRecId_maybe, tcInstId,
+ RecTcEnv, tcAddImportedIdInfo, tcLookupRecId, tcLookupRecId_maybe,
-- New Ids
newLocalId, newSpecPragmaId,
import RnHsSyn ( RenamedMonoBinds, RenamedSig )
import TcMonad
-import TcType ( TcKind, TcType, TcTyVar, TcTyVarSet, TcThetaType,
- tcInstTyVars, zonkTcTyVars,
+import TcType ( TcKind, TcType, TcTyVar, TcTyVarSet,
+ zonkTcTyVarsAndFV
)
import Id ( idName, mkUserLocal, isDataConWrapId_maybe )
import IdInfo ( constantIdInfo )
import VarSet
import Type ( Type,
tyVarsOfTypes, splitDFunTy,
- splitForAllTys, splitRhoTy,
getDFunTyKey, tyConAppTyCon
)
import DataCon ( DataCon )
import TyCon ( TyCon )
import Class ( Class, ClassOpItem, ClassContext )
-import Subst ( substTy )
import Name ( Name, OccName, NamedThing(..),
nameOccName, getSrcLoc, mkLocalName,
isLocalName, nameModule_maybe
%************************************************************************
%* *
-\subsection{Random useful functions}
-%* *
-%************************************************************************
-
-
-\begin{code}
--- A useful function that takes an occurrence of a global thing
--- and instantiates its type with fresh type variables
-tcInstId :: Id
- -> NF_TcM ([TcTyVar], -- It's instantiated type
- TcThetaType, --
- TcType) --
-tcInstId id
- = let
- (tyvars, rho) = splitForAllTys (idType id)
- in
- tcInstTyVars tyvars `thenNF_Tc` \ (tyvars', arg_tys, tenv) ->
- let
- rho' = substTy tenv rho
- (theta', tau') = splitRhoTy rho'
- in
- returnNF_Tc (tyvars', theta', tau')
-\end{code}
-
-
-%************************************************************************
-%* *
\subsection{Making new Ids}
%* *
%************************************************************************
tcLookupGlobalId name
= tcLookupGlobal_maybe name `thenNF_Tc` \ maybe_id ->
case maybe_id of
- Just (AnId clas) -> returnNF_Tc clas
- other -> notFound "tcLookupGlobalId" name
+ Just (AnId id) -> returnNF_Tc id
+ other -> notFound "tcLookupGlobalId" name
tcLookupDataCon :: Name -> TcM DataCon
tcLookupDataCon con_name
case maybe_tc of
Just (ATyCon tc) -> returnNF_Tc tc
other -> notFound "tcLookupTyCon" name
+
+tcLookupLocalIds :: [Name] -> NF_TcM [TcId]
+tcLookupLocalIds ns
+ = tcGetEnv `thenNF_Tc` \ env ->
+ returnNF_Tc (map (lookup (tcLEnv env)) ns)
+ where
+ lookup lenv name = case lookupNameEnv lenv name of
+ Just (ATcId id) -> id
+ other -> pprPanic "tcLookupLocalIds" (ppr name)
\end{code}
tcGetGlobalTyVars :: NF_TcM TcTyVarSet
tcGetGlobalTyVars
= tcGetEnv `thenNF_Tc` \ (TcEnv {tcTyVars = gtv_var}) ->
- tcReadMutVar gtv_var `thenNF_Tc` \ global_tvs ->
- zonkTcTyVars (varSetElems global_tvs) `thenNF_Tc` \ global_tys' ->
- let
- global_tvs' = (tyVarsOfTypes global_tys')
- in
- tcWriteMutVar gtv_var global_tvs' `thenNF_Tc_`
- returnNF_Tc global_tvs'
+ tcReadMutVar gtv_var `thenNF_Tc` \ gbl_tvs ->
+ zonkTcTyVarsAndFV (varSetElems gbl_tvs) `thenNF_Tc` \ gbl_tvs' ->
+ tcWriteMutVar gtv_var gbl_tvs' `thenNF_Tc_`
+ returnNF_Tc gbl_tvs'
\end{code}