[project @ 2000-10-24 08:40:09 by simonpj]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcTyDecls.lhs
index 2281538..c44fef2 100644 (file)
@@ -23,7 +23,10 @@ import BasicTypes    ( NewOrData(..) )
 import TcMonoType      ( tcHsType, tcHsSigType, tcHsBoxedSigType, tcHsTyVars, tcClassContext,
                          kcHsContext, kcHsSigType
                        )
-import TcEnv           ( tcExtendTyVarEnv, tcLookupTy, tcLookupValueByKey, TyThing(..), TyThingDetails(..) )
+import TcEnv           ( tcExtendTyVarEnv, 
+                         tcLookupTyCon, tcLookupClass, tcLookupGlobalId, 
+                         TyThingDetails(..)
+                       )
 import TcMonad
 
 import Class           ( ClassContext )
@@ -45,7 +48,7 @@ import Type           ( tyVarsOfTypes, splitFunTy, applyTys,
                        )
 import TysWiredIn      ( unitTy )
 import VarSet          ( intersectVarSet, isEmptyVarSet )
-import PrelNames       ( unpackCStringIdKey, unpackCStringUtf8IdKey )
+import PrelNames       ( unpackCStringName, unpackCStringUtf8Name )
 import ListSetOps      ( equivClasses )
 \end{code}
 
@@ -56,9 +59,9 @@ import ListSetOps     ( equivClasses )
 %************************************************************************
 
 \begin{code}
-tcTyDecl1 :: RenamedTyClDecl -> TcM s (Name, TyThingDetails)
+tcTyDecl1 :: RenamedTyClDecl -> TcM (Name, TyThingDetails)
 tcTyDecl1 (TySynonym tycon_name tyvar_names rhs src_loc)
-  = tcLookupTy tycon_name                      `thenNF_Tc` \ (ATyCon tycon) ->
+  = tcLookupTyCon tycon_name                   `thenNF_Tc` \ tycon ->
     tcExtendTyVarEnv (tyConTyVars tycon)       $
     tcHsType rhs                               `thenTc` \ rhs_ty ->
        -- Note tcHsType not tcHsSigType; we allow type synonyms
@@ -75,8 +78,8 @@ tcTyDecl1 (TySynonym tycon_name tyvar_names rhs src_loc)
 
     returnTc (tycon_name, SynTyDetails rhs_ty)
 
-tcTyDecl1 (TyData new_or_data context tycon_name _ con_decls _ derivings _ src_loc name1 name2)
-  = tcLookupTy tycon_name                      `thenNF_Tc` \ (ATyCon tycon) ->
+tcTyDecl1 (TyData new_or_data context tycon_name _ con_decls _ derivings src_loc name1 name2)
+  = tcLookupTyCon tycon_name                   `thenNF_Tc` \ tycon ->
     let
        tyvars = tyConTyVars tycon
     in
@@ -90,10 +93,7 @@ tcTyDecl1 (TyData new_or_data context tycon_name _ con_decls _ derivings _ src_l
     returnTc (tycon_name, DataTyDetails ctxt data_cons derived_classes)
   where
     tc_derivs Nothing   = returnTc []
-    tc_derivs (Just ds) = mapTc tc_deriv ds
-
-    tc_deriv name = tcLookupTy name `thenTc` \ (AClass clas) ->
-                   returnTc clas
+    tc_derivs (Just ds) = mapTc tcLookupClass ds
 \end{code}
 
 \begin{code}
@@ -125,7 +125,7 @@ mkNewTyConRep tc
 %************************************************************************
 
 \begin{code}
-kcConDetails :: RenamedContext -> ConDetails Name -> TcM s ()
+kcConDetails :: RenamedContext -> ConDetails Name -> TcM ()
 kcConDetails ex_ctxt details
   = kcHsContext ex_ctxt                `thenTc_`
     kc_con_details details
@@ -138,7 +138,7 @@ kcConDetails ex_ctxt details
 
     kc_bty bty = kcHsSigType (getBangType bty)
 
-tcConDecl :: NewOrData -> TyCon -> [TyVar] -> ClassContext -> RenamedConDecl -> TcM s DataCon
+tcConDecl :: NewOrData -> TyCon -> [TyVar] -> ClassContext -> RenamedConDecl -> TcM DataCon
 
 tcConDecl new_or_data tycon tyvars ctxt (ConDecl name wkr_name ex_tvs ex_ctxt details src_loc)
   = tcAddSrcLoc src_loc                                        $
@@ -216,7 +216,7 @@ getBangStrictness (Unpacked _) = markedUnboxed
 %************************************************************************
 
 \begin{code}
-mkImplicitDataBinds :: [TyCon] -> TcM s ([Id], TcMonoBinds)
+mkImplicitDataBinds :: [TyCon] -> TcM ([Id], TcMonoBinds)
 mkImplicitDataBinds [] = returnTc ([], EmptyMonoBinds)
 mkImplicitDataBinds (tycon : tycons) 
   | isSynTyCon tycon = mkImplicitDataBinds tycons
@@ -263,8 +263,8 @@ mkRecordSelector tycon fields@((first_con, first_field_label) : other_fields)
        -- data type use the same type variables
   = checkTc (all (== field_ty) other_tys)
            (fieldTypeMisMatch field_name)      `thenTc_`
-    tcLookupValueByKey unpackCStringIdKey      `thenTc` \ unpack_id ->
-    tcLookupValueByKey unpackCStringUtf8IdKey  `thenTc` \ unpackUtf8_id ->
+    tcLookupGlobalId unpackCStringName         `thenTc` \ unpack_id ->
+    tcLookupGlobalId unpackCStringUtf8Name     `thenTc` \ unpackUtf8_id ->
     returnTc (mkRecordSelId tycon first_field_label unpack_id unpackUtf8_id)
   where
     field_ty   = fieldLabelType first_field_label