projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
update submodule pointer
[ghc-hetmet.git]
/
compiler
/
typecheck
/
TcEnv.lhs
diff --git
a/compiler/typecheck/TcEnv.lhs
b/compiler/typecheck/TcEnv.lhs
index
d6177b4
..
c6789f4
100644
(file)
--- a/
compiler/typecheck/TcEnv.lhs
+++ b/
compiler/typecheck/TcEnv.lhs
@@
-29,6
+29,7
@@
module TcEnv(
tcLookupId, tcLookupTyVar, getScopedTyVarBinds,
getInLocalScope,
wrongThingErr, pprBinders,
tcLookupId, tcLookupTyVar, getScopedTyVarBinds,
getInLocalScope,
wrongThingErr, pprBinders,
+ getHetMetLevel,
tcExtendRecEnv, -- For knot-tying
tcExtendRecEnv, -- For knot-tying
@@
-203,6
+204,7
@@
tcLookupFamInst tycon tys
= do { env <- getGblEnv
; eps <- getEps
; let instEnv = (eps_fam_inst_env eps, tcg_fam_inst_env env)
= do { env <- getGblEnv
; eps <- getEps
; let instEnv = (eps_fam_inst_env eps, tcg_fam_inst_env env)
+ ; traceTc "lookupFamInst" ((ppr tycon <+> ppr tys) $$ ppr instEnv)
; case lookupFamInstEnv instEnv tycon tys of
[] -> return Nothing
((fam_inst, rep_tys):_)
; case lookupFamInstEnv instEnv tycon tys of
[] -> return Nothing
((fam_inst, rep_tys):_)
@@
-404,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
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
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
tcExtendGhciEnv :: [TcId] -> TcM a -> TcM a
-- Used to bind Ids for GHCi identifiers bound earlier in the user interaction
@@
-417,11
+427,13
@@
tcExtendGhciEnv :: [TcId] -> TcM a -> TcM a
-- GHCi has already compiled it to bytecode
tcExtendGhciEnv ids thing_inside
= do { env <- getLclEnv
-- 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
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:
-> [(Name,TcId)]
-> TcM a -> TcM a
-- Invariant: the TcIds are fully zonked. Reasons:
@@
-431,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
-- 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'}
= 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'}
@@
-439,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,
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]
| (name,id) <- names_w_ids]
le' = extendNameEnvList (tcl_env env) extra_env
rdr_env' = extendLocalRdrEnvList (tcl_rdr env) [name | (name,_) <- names_w_ids]
@@
-548,9
+562,9
@@
tcGetDefaultTys :: Bool -- True <=> interactive context
Bool)) -- True <=> Use extended defaulting rules
tcGetDefaultTys interactive
= do { dflags <- getDOpts
Bool)) -- True <=> Use extended defaulting rules
tcGetDefaultTys interactive
= do { dflags <- getDOpts
- ; let ovl_strings = dopt Opt_OverloadedStrings dflags
+ ; let ovl_strings = xopt Opt_OverloadedStrings dflags
extended_defaults = interactive
extended_defaults = interactive
- || dopt Opt_ExtendedDefaultRules dflags
+ || xopt Opt_ExtendedDefaultRules dflags
-- See also Trac #1974
flags = (ovl_strings, extended_defaults)
-- See also Trac #1974
flags = (ovl_strings, extended_defaults)
@@
-606,8
+620,8
@@
as well as explicit user written ones.
\begin{code}
data InstInfo a
= InstInfo {
\begin{code}
data InstInfo a
= InstInfo {
- iSpec :: Instance, -- Includes the dfun id. Its forall'd type
- iBinds :: InstBindings a -- variables scope over the stuff in InstBindings!
+ iSpec :: Instance, -- Includes the dfun id. Its forall'd type
+ iBinds :: InstBindings a -- variables scope over the stuff in InstBindings!
}
iDFunId :: InstInfo a -> DFunId
}
iDFunId :: InstInfo a -> DFunId
@@
-637,7
+651,13
@@
data InstBindings a
-- in TcDeriv
pprInstInfo :: InstInfo a -> SDoc
-- in TcDeriv
pprInstInfo :: InstInfo a -> SDoc
-pprInstInfo info = vcat [ptext (sLit "InstInfo:") <+> ppr (idType (iDFunId info))]
+pprInstInfo info = hang (ptext (sLit "instance"))
+ 2 (sep [ ifPprDebug (pprForAll tvs)
+ , pprThetaArrow theta, ppr tau
+ , ptext (sLit "where")])
+ where
+ (tvs, theta, tau) = tcSplitSigmaTy (idType (iDFunId info))
+
pprInstInfoDetails :: OutputableBndr a => InstInfo a -> SDoc
pprInstInfoDetails info = pprInstInfo info $$ nest 2 (details (iBinds info))
pprInstInfoDetails :: OutputableBndr a => InstInfo a -> SDoc
pprInstInfoDetails info = pprInstInfo info $$ nest 2 (details (iBinds info))