import TcForeign ( tcForeignImports, tcForeignExports )
import TcIfaceSig ( tcInterfaceSigs )
import TcInstDcls ( tcInstDecls1, tcInstDecls2 )
-import TcInstUtil ( InstInfo(..) )
+import InstEnv ( InstInfo(..) )
import TcSimplify ( tcSimplifyTop )
import TcTyClsDecls ( tcTyAndClassDecls )
import TcTyDecls ( mkImplicitDataBinds )
import Bag ( isEmptyBag )
import ErrUtils ( printErrorsAndWarnings, dumpIfSet_dyn )
import Id ( idType, idName, idUnfolding )
-import Module ( Module, moduleName, {-mkThisModule,-} plusModuleEnv )
-import Name ( nameOccName, isLocallyDefined, isGlobalName,
- toRdrName, nameEnvElts, emptyNameEnv
+import Module ( Module, moduleName, plusModuleEnv )
+import Name ( Name, nameOccName, isLocallyDefined, isGlobalName,
+ toRdrName, nameEnvElts, emptyNameEnv, lookupNameEnv
)
import TyCon ( TyCon, isDataTyCon, tyConName, tyConGenInfo )
import OccName ( isSysOcc )
import Class ( Class )
import PrelNames ( mAIN_Name, mainName )
import UniqSupply ( UniqSupply )
-import Maybes ( maybeToBool )
+import Maybes ( maybeToBool, thenMaybe )
import Util
-import BasicTypes ( EP(..) )
+import BasicTypes ( EP(..), Fixity )
import Bag ( Bag, isEmptyBag )
import Outputable
-import HscTypes ( PersistentCompilerState(..), HomeSymbolTable,
- PackageSymbolTable, DFunId,
- TypeEnv, extendTypeEnv,
+import HscTypes ( PersistentCompilerState(..), HomeSymbolTable, HomeIfaceTable,
+ PackageSymbolTable, PackageIfaceTable, DFunId, ModIface(..),
+ TypeEnv, extendTypeEnv, lookupTable,
TyThing(..), groupTyThings )
import FiniteMap ( FiniteMap, delFromFM, lookupWithDefaultFM )
\end{code}
---------------
typecheckModule
:: DynFlags
+ -> Module
-> PersistentCompilerState
-> HomeSymbolTable
+ -> HomeIfaceTable
+ -> PackageIfaceTable
-> RenamedHsModule
-> IO (Maybe (TcEnv, TcResults))
-typecheckModule dflags pcs hst (HsModule mod_name _ _ _ decls _ src_loc)
+typecheckModule dflags this_mod pcs hst hit pit (HsModule mod_name _ _ _ decls _ src_loc)
= do env <- initTcEnv global_symbol_table
(maybe_result, (errs,warns)) <- initTc dflags env src_loc tc_module
printErrorsAndWarnings (errs,warns)
else
return maybe_result
where
- this_mod = panic "mkThisModule: unimp" -- WAS: mkThisModule
global_symbol_table = pcs_PST pcs `plusModuleEnv` hst
- tc_module = fixTc (\ ~(unf_env ,_) -> tcModule pcs hst this_mod decls unf_env)
+ tc_module = fixTc (\ ~(unf_env ,_)
+ -> tcModule pcs hst get_fixity this_mod decls unf_env)
+
+ get_fixity :: Name -> Maybe Fixity
+ get_fixity nm = lookupTable hit pit nm `thenMaybe` \ iface ->
+ lookupNameEnv (mi_fixities iface) nm
\end{code}
The internal monster:
\begin{code}
tcModule :: PersistentCompilerState
-> HomeSymbolTable
+ -> (Name -> Maybe Fixity)
-> Module
-> [RenamedHsDecl]
-> TcEnv -- The knot-tied environment
-- unf_env is also used to get the pragama info
-- for imported dfuns and default methods
-tcModule pcs hst this_mod decls unf_env
+tcModule pcs hst get_fixity this_mod decls unf_env
= -- Type-check the type and class decls
tcTyAndClassDecls unf_env decls `thenTc` \ env ->
tcSetEnv env $
in
-- Typecheck the instance decls, includes deriving
- tcInstDecls1 pcs hst unf_env this_mod
+ tcInstDecls1 pcs hst unf_env get_fixity this_mod
local_tycons decls `thenTc` \ (pcs_with_insts, inst_env, inst_info, deriv_binds) ->
tcSetInstEnv inst_env $