[project @ 2003-08-19 22:09:09 by krc]
[ghc-hetmet.git] / ghc / compiler / main / HscTypes.lhs
index 88248a0..88fd6b9 100644 (file)
@@ -14,7 +14,7 @@ module HscTypes (
 
        HomePackageTable, HomeModInfo(..), emptyHomePackageTable,
 
-       ExternalPackageState(..), 
+       ExternalPackageState(..),  emptyExternalPackageState,
        PackageTypeEnv, PackageIfaceTable, emptyPackageIfaceTable,
        lookupIface, lookupIfaceByModName, moduleNameToModule,
        emptyModIface,
@@ -96,9 +96,11 @@ import RnHsSyn               ( RenamedTyClDecl, RenamedRuleDecl, RenamedInstDecl )
 
 import CoreSyn         ( IdCoreRule )
 import PrelNames       ( isBuiltInSyntaxName )
+import InstEnv         ( emptyInstEnv )
+import Rules           ( emptyRuleBase )
 
 import FiniteMap
-import Bag             ( Bag )
+import Bag             ( Bag, emptyBag )
 import Maybes          ( orElse )
 import Outputable
 import SrcLoc          ( SrcLoc, isGoodSrcLoc )
@@ -455,7 +457,7 @@ implicitTyThings things
        -- Newtypes don't have a worker Id, so don't generate that
     extras (ATyCon tc) = map AnId (tyConGenIds tc ++ tyConSelIds tc) ++ data_con_stuff
        where
-       data_con_stuff | isNewTyCon tc = [ADataCon dc1, AnId (dataConWrapId dc1)]
+       data_con_stuff | isNewTyCon tc = (if (null dcs) then [] else  [ADataCon dc1, AnId (dataConWrapId dc1)]) 
                       | otherwise     = concatMap (extras_plus . ADataCon) dcs
        dcs = tyConDataCons tc
        dc1 = head dcs
@@ -677,7 +679,8 @@ compiler.
 data PersistentCompilerState 
    = PCS {
        pcs_nc  :: !NameCache,
-        pcs_EPS :: !ExternalPackageState
+        pcs_EPS :: ExternalPackageState
+               -- non-strict because we fill it with error in HscMain
      }
 \end{code}
 
@@ -729,6 +732,17 @@ data ExternalPackageState
                -- for the home package we have all the instance
                -- declarations anyhow
   }
+
+emptyExternalPackageState = EPS { 
+      eps_decls      = (emptyNameEnv, 0),
+      eps_insts      = (emptyBag, 0),
+      eps_inst_gates = emptyNameSet,
+      eps_rules      = (emptyBag, 0),
+      eps_PIT        = emptyPackageIfaceTable,
+      eps_PTE        = emptyTypeEnv,
+      eps_inst_env   = emptyInstEnv,
+      eps_rule_base  = emptyRuleBase
+   }
 \end{code}
 
 The NameCache makes sure that there is just one Unique assigned for