X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcEnv.lhs;h=94daff05effce3077a785d7a584f21618c4dd3d7;hp=b5884a742a49d02703b272085b13532d305bd5e3;hb=HEAD;hpb=2a26efb65343e31957b043f63c43caf24d5eeb30 diff --git a/compiler/typecheck/TcEnv.lhs b/compiler/typecheck/TcEnv.lhs index b5884a7..94daff0 100644 --- a/compiler/typecheck/TcEnv.lhs +++ b/compiler/typecheck/TcEnv.lhs @@ -29,6 +29,7 @@ module TcEnv( tcLookupId, tcLookupTyVar, getScopedTyVarBinds, getInLocalScope, wrongThingErr, pprBinders, + getHetMetLevel, tcExtendRecEnv, -- For knot-tying @@ -405,11 +406,19 @@ tcExtendIdEnv ids thing_inside = tcExtendIdEnv2 [(idName id, id) | id <- ids] th tcExtendIdEnv1 :: Name -> TcId -> TcM a -> TcM a tcExtendIdEnv1 name id thing_inside = tcExtendIdEnv2 [(name,id)] thing_inside +getHetMetLevel :: TcM [TyVar] +getHetMetLevel = + do { env <- getEnv + ; return $ case env of Env { env_lcl = e' } -> case e' of TcLclEnv { tcl_hetMetLevel = x } -> x + } + tcExtendIdEnv2 :: [(Name,TcId)] -> TcM a -> TcM a -- Invariant: the TcIds are fully zonked (see tcExtendIdEnv above) tcExtendIdEnv2 names_w_ids thing_inside = do { env <- getLclEnv - ; tc_extend_local_id_env env (thLevel (tcl_th_ctxt env)) names_w_ids thing_inside } + ; hetMetLevel <- getHetMetLevel + ; tc_extend_local_id_env env (thLevel (tcl_th_ctxt env)) hetMetLevel names_w_ids thing_inside } + tcExtendGhciEnv :: [TcId] -> TcM a -> TcM a -- Used to bind Ids for GHCi identifiers bound earlier in the user interaction @@ -418,11 +427,13 @@ tcExtendGhciEnv :: [TcId] -> TcM a -> TcM a -- GHCi has already compiled it to bytecode tcExtendGhciEnv ids thing_inside = do { env <- getLclEnv - ; tc_extend_local_id_env env impLevel [(idName id, id) | id <- ids] thing_inside } + ; hetMetLevel <- getHetMetLevel + ; tc_extend_local_id_env env impLevel hetMetLevel [(idName id, id) | id <- ids] thing_inside } tc_extend_local_id_env -- This is the guy who does the work :: TcLclEnv -> ThLevel + -> [TyVar] -> [(Name,TcId)] -> TcM a -> TcM a -- Invariant: the TcIds are fully zonked. Reasons: @@ -432,7 +443,7 @@ tc_extend_local_id_env -- This is the guy who does the work -- in the types, because instantiation does not look through such things -- (c) The call to tyVarsOfTypes is ok without looking through refs -tc_extend_local_id_env env th_lvl names_w_ids thing_inside +tc_extend_local_id_env env th_lvl hetMetLevel names_w_ids thing_inside = do { traceTc "env2" (ppr extra_env) ; gtvs' <- tcExtendGlobalTyVars (tcl_tyvars env) extra_global_tyvars ; let env' = env {tcl_env = le', tcl_tyvars = gtvs', tcl_rdr = rdr_env'} @@ -440,7 +451,9 @@ tc_extend_local_id_env env th_lvl names_w_ids thing_inside where extra_global_tyvars = tcTyVarsOfTypes [idType id | (_,id) <- names_w_ids] extra_env = [ (name, ATcId { tct_id = id, - tct_level = th_lvl }) + tct_level = th_lvl, + tct_hetMetLevel = hetMetLevel + }) | (name,id) <- names_w_ids] le' = extendNameEnvList (tcl_env env) extra_env rdr_env' = extendLocalRdrEnvList (tcl_rdr env) [name | (name,_) <- names_w_ids] @@ -626,7 +639,7 @@ data InstBindings a -- witness dictionary is identical to the argument -- dictionary. Hence no bindings, no pragmas. - CoercionI -- The coercion maps from newtype to the representation type + Coercion -- The coercion maps from newtype to the representation type -- (mentioning type variables bound by the forall'd iSpec variables) -- E.g. newtype instance N [a] = N1 (Tree a) -- co : N [a] ~ Tree a @@ -640,7 +653,7 @@ data InstBindings a pprInstInfo :: InstInfo a -> SDoc pprInstInfo info = hang (ptext (sLit "instance")) 2 (sep [ ifPprDebug (pprForAll tvs) - , pprThetaArrow theta, ppr tau + , pprThetaArrowTy theta, ppr tau , ptext (sLit "where")]) where (tvs, theta, tau) = tcSplitSigmaTy (idType (iDFunId info))