import RnHsSyn ( RenamedHsBinds, RenamedHsDecl, RenamedHsExpr )
import TcHsSyn ( TypecheckedMonoBinds, TypecheckedHsExpr,
TypecheckedForeignDecl, TypecheckedRuleDecl,
- zonkTopBinds, zonkForeignExports, zonkRules, mkHsLet
+ zonkTopBinds, zonkForeignExports, zonkRules, mkHsLet,
+ zonkExpr
)
import TcMonad
-import TcType ( newTyVarTy )
+import TcType ( newTyVarTy, zonkTcType )
import Inst ( plusLIE )
import TcBinds ( tcTopBinds )
import TcClassDcl ( tcClassDecls2 )
import TcDefaults ( tcDefaults, defaultDefaultTys )
import TcExpr ( tcMonoExpr )
-import TcEnv ( TcEnv, InstInfo(iDFunId), tcExtendGlobalValEnv,
+import TcEnv ( TcEnv, InstInfo, tcExtendGlobalValEnv,
isLocalThing, tcSetEnv, tcSetInstEnv, initTcEnv, getTcGEnv
)
import TcRules ( tcIfaceRules, tcSourceRules )
import CoreUnfold ( unfoldingTemplate, hasUnfolding )
import Type ( funResultTy, splitForAllTys, openTypeKind )
import Bag ( isEmptyBag )
-import ErrUtils ( printErrorsAndWarnings, dumpIfSet_dyn, showPass )
+import ErrUtils ( printErrorsAndWarnings, errorsFound, dumpIfSet_dyn, showPass )
import Id ( idType, idUnfolding )
import Module ( Module )
import Name ( Name, toRdrName )
import TyCon ( tyConGenInfo )
import Util
import BasicTypes ( EP(..), Fixity )
-import Bag ( isEmptyBag )
import Outputable
import HscTypes ( PersistentCompilerState(..), HomeSymbolTable,
- PackageTypeEnv, DFunId, ModIface(..),
+ PackageTypeEnv, ModIface(..),
TypeEnv, extendTypeEnvList,
TyThing(..), implicitTyThingIds,
mkTypeEnv
= TcResults {
-- All these fields have info *just for this module*
tc_env :: TypeEnv, -- The top level TypeEnv
- tc_insts :: [DFunId], -- Instances
tc_binds :: TypecheckedMonoBinds, -- Bindings
tc_fords :: [TypecheckedForeignDecl], -- Foreign import & exports.
tc_rules :: [TypecheckedRuleDecl] -- Transformation rules
-> Module
-> (RenamedHsExpr, -- The expression itself
[RenamedHsDecl]) -- Plus extra decls it sucked in from interface files
- -> IO (Maybe (PersistentCompilerState, TypecheckedHsExpr))
+ -> IO (Maybe (PersistentCompilerState, TypecheckedHsExpr, TcType))
typecheckExpr dflags pcs hst unqual this_mod (expr, decls)
= typecheck dflags pcs hst unqual $
newTyVarTy openTypeKind `thenTc` \ ty ->
tcMonoExpr expr ty `thenTc` \ (expr', lie) ->
tcSimplifyTop lie `thenTc` \ binds ->
- returnTc (new_pcs, mkHsLet binds expr')
+ let all_expr = mkHsLet binds expr' in
+ zonkExpr all_expr `thenNF_Tc` \ zonked_expr ->
+ zonkTcType ty `thenNF_Tc` \ zonked_ty ->
+ returnTc (new_pcs, zonked_expr, zonked_ty)
where
get_fixity :: Name -> Maybe Fixity
get_fixity n = pprPanic "typecheckExpr" (ppr n)
= do { showPass dflags "Typechecker";
; env <- initTcEnv hst (pcs_PTE pcs)
- ; (maybe_tc_result, (warns,errs)) <- initTc dflags env thing_inside
+ ; (maybe_tc_result, errs) <- initTc dflags env thing_inside
- ; printErrorsAndWarnings unqual (errs,warns)
+ ; printErrorsAndWarnings unqual errs
- ; if isEmptyBag errs then
- return maybe_tc_result
- else
+ ; if errorsFound errs then
return Nothing
+ else
+ return maybe_tc_result
}
\end{code}
returnTc (new_pcs,
TcResults { tc_env = local_type_env,
tc_binds = implicit_binds `AndMonoBinds` all_binds',
- tc_insts = map iDFunId local_inst_info,
tc_fords = foi_decls ++ foe_decls',
tc_rules = all_local_rules
}