tcExtendTyConEnv, tcLookupTyCon, tcLookupTyConByKey,
tcExtendClassEnv, tcLookupClass, tcLookupClassByKey,
tcExtendTyConEnv, tcLookupTyCon, tcLookupTyConByKey,
tcExtendClassEnv, tcLookupClass, tcLookupClassByKey,
tcExtendGlobalValEnv, tcExtendLocalValEnv,
tcLookupLocalValue, tcLookupLocalValueOK, tcLookupLocalValueByKey,
tcLookupGlobalValue, tcLookupGlobalValueByKey,
newMonoIds, newLocalIds, newLocalId,
tcExtendGlobalValEnv, tcExtendLocalValEnv,
tcLookupLocalValue, tcLookupLocalValueOK, tcLookupLocalValueByKey,
tcLookupGlobalValue, tcLookupGlobalValueByKey,
newMonoIds, newLocalIds, newLocalId,
-import Id ( Id(..), GenId, idType, mkUserLocal )
-import TcHsSyn ( TcIdBndr(..), TcIdOcc(..) )
+import Id ( SYN_IE(Id), GenId, idType, mkUserLocal )
+import TcHsSyn ( SYN_IE(TcIdBndr), TcIdOcc(..) )
import TcKind ( TcKind, newKindVars, tcDefaultKind, kindToTcKind )
import TcKind ( TcKind, newKindVars, tcDefaultKind, kindToTcKind )
-import TcType ( TcType(..), TcMaybe, TcTyVar(..), TcTyVarSet(..),
- newTyVarTys, tcInstTyVars, tcInstType, zonkTcTyVars
+import TcType ( SYN_IE(TcType), TcMaybe, SYN_IE(TcTyVar), SYN_IE(TcTyVarSet),
+ newTyVarTys, tcInstTyVars, zonkTcTyVars
-import TyVar ( mkTyVar, getTyVarKind, unionTyVarSets, emptyTyVarSet )
-import Type ( tyVarsOfTypes )
-import TyCon ( TyCon, Arity(..), tyConKind, synTyConArity )
-import Class ( Class(..), GenClass, getClassSig )
+import TyVar ( mkTyVar, tyVarKind, unionTyVarSets, emptyTyVarSet )
+import Type ( tyVarsOfTypes, splitForAllTy )
+import TyCon ( TyCon, tyConKind, synTyConArity )
+import Class ( SYN_IE(Class), GenClass, classSig )
import Name ( getOccName, getSrcLoc, Name{-instance NamedThing-} )
import PprStyle
import Pretty
import RnHsSyn ( RnName(..) )
import Name ( getOccName, getSrcLoc, Name{-instance NamedThing-} )
import PprStyle
import Pretty
import RnHsSyn ( RnName(..) )
-import Util ( zipWithEqual, zipWith3Equal, zipLazy, panic, pprPanic )
+import Util ( zipEqual, zipWithEqual, zipWith3Equal, zipLazy,
+ panic, pprPanic{-, pprTrace ToDo:rm-}
+ )
in
returnTc (tyvars, result)
) `thenTc` \ (_,result) ->
in
returnTc (tyvars, result)
) `thenTc` \ (_,result) ->
tcGetEnv `thenNF_Tc` \ (TcEnv tve tce ce gve lve gtvs) ->
let
tce' = addListToUFM tce [ (name, (kind, arity, tycon))
tcGetEnv `thenNF_Tc` \ (TcEnv tve tce ce gve lve gtvs) ->
let
tce' = addListToUFM tce [ (name, (kind, arity, tycon))
- | ((name,arity), (kind,tycon)) <- names_w_arities `zip`
- (kinds `zipLazy` tycons)
+ | ((name,arity), (kind,tycon))
+ <- zipEqual "tcExtendTyConEnv" names_w_arities (kinds `zipLazy` tycons)
= newKindVars (length names) `thenNF_Tc` \ kinds ->
tcGetEnv `thenNF_Tc` \ (TcEnv tve tce ce gve lve gtvs) ->
let
= newKindVars (length names) `thenNF_Tc` \ kinds ->
tcGetEnv `thenNF_Tc` \ (TcEnv tve tce ce gve lve gtvs) ->
let
in
tcSetEnv (TcEnv tve tce ce' gve lve gtvs) scope `thenTc` \ result ->
mapNF_Tc tcDefaultKind kinds `thenNF_Tc_`
in
tcSetEnv (TcEnv tve tce ce' gve lve gtvs) scope `thenTc` \ result ->
mapNF_Tc tcDefaultKind kinds `thenNF_Tc_`
tcLookupTyConByKey uniq
= tcGetEnv `thenNF_Tc` \ (TcEnv tve tce ce gve lve gtvs) ->
let
(kind, arity, tycon) = lookupWithDefaultUFM_Directly tce
tcLookupTyConByKey uniq
= tcGetEnv `thenNF_Tc` \ (TcEnv tve tce ce gve lve gtvs) ->
let
(kind, arity, tycon) = lookupWithDefaultUFM_Directly tce
- returnNF_Tc (lookupWithDefaultUFM ce (panic "tcLookupClass") name)
+-- pprTrace "tcLookupClass:" (ppCat [ppStr "Uniq:", pprUnique10 (uniqueOf name), ppStr "; avail:", ppCat (map (pprUnique10 . fst) (ufmToList ce))]) $
+-- pprTrace "tcLookupClass:" (ppCat [ppStr "Uniq:", pprUnique (uniqueOf name), ppStr "; avail:", ppCat (map (pprUnique . fst) (ufmToList ce))]) $
+ returnNF_Tc (lookupWithDefaultUFM ce (pprPanic "tcLookupClass:" (ppr PprShowAll name)) name)
tcLookupClassByKey uniq
= tcGetEnv `thenNF_Tc` \ (TcEnv tve tce ce gve lve gtvs) ->
let
(kind, clas) = lookupWithDefaultUFM_Directly ce
tcLookupClassByKey uniq
= tcGetEnv `thenNF_Tc` \ (TcEnv tve tce ce gve lve gtvs) ->
let
(kind, clas) = lookupWithDefaultUFM_Directly ce
+
+tcGetTyConsAndClasses :: NF_TcM s ([TyCon], [Class])
+tcGetTyConsAndClasses
+ = tcGetEnv `thenNF_Tc` \ (TcEnv tve tce ce gve lve gtvs) ->
+ returnNF_Tc ([tc | (_, _, tc) <- eltsUFM tce],
+ [c | (_, c) <- eltsUFM ce])
= tcGetEnv `thenNF_Tc` \ (TcEnv tve tce ce gve lve gtvs) ->
tcReadMutVar gtvs `thenNF_Tc` \ global_tvs ->
let
= tcGetEnv `thenNF_Tc` \ (TcEnv tve tce ce gve lve gtvs) ->
tcReadMutVar gtvs `thenNF_Tc` \ global_tvs ->
let
extra_global_tyvars = tyVarsOfTypes (map idType ids)
new_global_tyvars = global_tvs `unionTyVarSets` extra_global_tyvars
in
extra_global_tyvars = tyVarsOfTypes (map idType ids)
new_global_tyvars = global_tvs `unionTyVarSets` extra_global_tyvars
in
+
+tcExtendGlobalTyVars extra_global_tvs scope
+ = tcGetEnv `thenNF_Tc` \ (TcEnv tve tce ce gve lve gtvs) ->
+ tcReadMutVar gtvs `thenNF_Tc` \ global_tvs ->
+ let
+ new_global_tyvars = global_tvs `unionTyVarSets` extra_global_tvs
+ in
+ tcNewMutVar new_global_tyvars `thenNF_Tc` \ gtvs' ->
+ tcSetEnv (TcEnv tve tce ce gve lve gtvs') scope