[project @ 2001-03-08 12:07:38 by simonpj]
[ghc-hetmet.git] / ghc / compiler / main / HscTypes.lhs
index f52f2cd..c358e8e 100644 (file)
@@ -18,7 +18,7 @@ module HscTypes (
 
        IfaceDecls, mkIfaceDecls, dcl_tycl, dcl_rules, dcl_insts,
 
-       VersionInfo(..), initialVersionInfo,
+       VersionInfo(..), initialVersionInfo, lookupVersion,
 
        TyThing(..), isTyClThing, implicitTyThingIds,
 
@@ -52,7 +52,7 @@ module HscTypes (
 
 import RdrName         ( RdrNameEnv, addListToRdrEnv, emptyRdrEnv, mkRdrUnqual, rdrEnvToList )
 import Name            ( Name, NamedThing, getName, nameOccName, nameModule, nameSrcLoc )
-import Name -- Env
+import NameEnv
 import OccName         ( OccName )
 import Module          ( Module, ModuleName, ModuleEnv,
                          lookupModuleEnv, lookupModuleEnvByName, emptyModuleEnv
@@ -74,7 +74,7 @@ import CoreSyn                ( IdCoreRule )
 
 import FiniteMap       ( FiniteMap )
 import Bag             ( Bag )
-import Maybes          ( seqMaybe )
+import Maybes          ( seqMaybe, orElse )
 import Outputable
 import SrcLoc          ( SrcLoc, isGoodSrcLoc )
 import Util            ( thenCmp, sortLt )
@@ -169,6 +169,25 @@ data ModDetails
         md_insts    :: [DFunId],       -- Dfun-ids for the instances in this module
         md_rules    :: [IdCoreRule]    -- Domain may include Ids from other modules
      }
+
+--     NOT YET IMPLEMENTED
+-- The ModDetails takes on several slightly different forms:
+--
+-- After typecheck + desugar
+--     md_types        contains TyCons, Classes, and hasNoBinding Ids
+--     md_insts        all instances from this module (incl derived ones)
+--     md_rules        all rules from this module
+--     md_binds        desugared bindings
+--
+-- After simplification
+--     md_types        same as after typecheck
+--     md_insts        ditto
+--     md_rules        orphan rules only (local ones attached to binds)
+--     md_binds        with rules attached
+--
+-- After tidy 
+--     md_types        now contains Ids as well, replete with correct IdInfo
+--                     apart from
 \end{code}
 
 \begin{code}
@@ -339,13 +358,19 @@ data VersionInfo
                -- The version of an Id changes if its fixity changes
                -- Ditto data constructors, class operations, except that the version of
                -- the parent class/tycon changes
+               --
+               -- If a name isn't in the map, it means 'initialVersion'
     }
 
 initialVersionInfo :: VersionInfo
 initialVersionInfo = VersionInfo { vers_module  = initialVersion,
                                   vers_exports = initialVersion,
                                   vers_rules   = initialVersion,
-                                  vers_decls   = emptyNameEnv }
+                                  vers_decls   = emptyNameEnv
+                       }
+
+lookupVersion :: NameEnv Version -> Name -> Version
+lookupVersion env name = lookupNameEnv env name `orElse` initialVersion
 
 data Deprecations = NoDeprecs
                  | DeprecAll DeprecTxt                         -- Whole module deprecated