[project @ 2005-01-31 13:22:57 by simonpj]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcRnTypes.lhs
index 3b71b1d..063017e 100644 (file)
@@ -9,7 +9,7 @@ module TcRnTypes(
        -- The environment types
        Env(..), 
        TcGblEnv(..), TcLclEnv(..), 
-       IfGblEnv(..), IfLclEnv(..),
+       IfGblEnv(..), IfLclEnv(..), 
 
        -- Ranamer types
        ErrCtxt,
@@ -45,10 +45,10 @@ import HsSyn                ( PendingSplice, HsOverLit, LRuleDecl, LForeignDecl,
                          ArithSeqInfo, DictBinds, LHsBinds )
 import HscTypes                ( FixityEnv,
                          HscEnv, TypeEnv, TyThing, 
-                         GenAvailInfo(..), AvailInfo,
+                         GenAvailInfo(..), AvailInfo, HscSource(..),
                          availName, IsBootInterface, Deprecations )
 import Packages                ( PackageId )
-import Type            ( Type, TvSubstEnv )
+import Type            ( Type, TvSubstEnv, pprParendType )
 import TcType          ( TcTyVarSet, TcType, TcTauType, TcThetaType, SkolemInfo,
                          TcPredType, TcKind, tcCmpPred, tcCmpType, tcCmpTypes )
 import InstEnv         ( DFunId, InstEnv )
@@ -129,6 +129,9 @@ data Env gbl lcl    -- Changes as we move into an expression
 data TcGblEnv
   = TcGblEnv {
        tcg_mod     :: Module,          -- Module being compiled
+       tcg_src     :: HscSource,       -- What kind of module 
+                                       -- (regular Haskell, hs-boot, ext-core)
+
        tcg_rdr_env :: GlobalRdrEnv,    -- Top level envt; used during renaming
        tcg_default :: Maybe [Type],    -- Types used for defaulting
                                        -- Nothing => no 'default' decl
@@ -232,6 +235,13 @@ data IfLclEnv
        -- it means M.f = \x -> x, where M is the if_mod
        if_mod :: Module,
 
+       -- The field is used only for error reporting
+       -- if (say) there's a Lint error in it
+       if_loc :: SDoc,
+               -- Where the interface came from:
+               --      .hi file, or GHCi state, or ext core
+               -- plus which bit is currently being examined
+
        if_tv_env  :: OccEnv TyVar,     -- Nested tyvar bindings
        if_id_env  :: OccEnv Id         -- Nested id binding
     }
@@ -386,15 +396,22 @@ topArrowCtxt = ArrCtxt { proc_level = topProcLevel, proc_banned = [] }
 
 data TcTyThing
   = AGlobal TyThing                    -- Used only in the return type of a lookup
+
   | ATcId   TcId ThLevel ProcLevel     -- Ids defined in this module; may not be fully zonked
-  | ATyVar  TyVar                      -- Type variables
+
+  | ATyVar  Name TcType                        -- Type variables; tv -> type.  It can't just be a TyVar
+                                       -- that is mutated to point to the type it is bound to,
+                                       -- because that would make it a wobbly type, and we
+                                       -- want pattern-bound lexically-scoped type variables to
+                                       -- be able to stand for rigid types
+
   | AThing  TcKind                     -- Used temporarily, during kind checking, for the
                                        --      tycons and clases in this recursive group
 
 instance Outputable TcTyThing where    -- Debugging only
    ppr (AGlobal g)      = text "AGlobal" <+> ppr g
    ppr (ATcId g tl pl)  = text "ATcId" <+> ppr g <+> ppr tl <+> ppr pl
-   ppr (ATyVar t)       = text "ATyVar" <+> ppr t
+   ppr (ATyVar tv ty)   = text "ATyVar" <+> ppr tv <+> pprParendType ty
    ppr (AThing k)       = text "AThing" <+> ppr k
 \end{code}