[project @ 2001-12-20 11:19:05 by simonpj]
[ghc-hetmet.git] / ghc / compiler / rename / RnHiFiles.lhs
index 0a11bfe..fbf9e79 100644 (file)
@@ -29,7 +29,7 @@ import HscTypes               ( ModuleLocation(..),
                         )
 import HsSyn           ( TyClDecl(..), InstDecl(..),
                          HsType(..), HsPred(..), FixitySig(..), RuleDecl(..),
-                         tyClDeclNames, tyClDeclSysNames, hsTyVarNames
+                         tyClDeclNames, tyClDeclSysNames, hsTyVarNames, getHsInstHead,
                        )
 import RdrHsSyn                ( RdrNameTyClDecl, RdrNameInstDecl, RdrNameRuleDecl )
 import RnHsSyn         ( extractHsTyNames_s )
@@ -384,7 +384,7 @@ loadInstDecl mod insts decl@(InstDecl inst_ty _ _ _ _)
        rnHsType (text "In an interface instance decl") inst_ty
     )                                  `thenRn` \ inst_ty' ->
     let 
-       (tvs,(cls,tys)) = get_head inst_ty'
+       (tvs,(cls,tys)) = getHsInstHead inst_ty'
        free_tcs  = nameSetToList (extractHsTyNames_s tys) `minusList` hsTyVarNames tvs
 
        gate_fn vis_fn = vis_fn cls && (null free_tcs || any vis_fn free_tcs)
@@ -395,22 +395,6 @@ loadInstDecl mod insts decl@(InstDecl inst_ty _ _ _ _)
     returnRn ((gate_fn, (mod, decl)) `consBag` insts)
 
 
--- In interface files, the instance decls now look like
---     forall a. Foo a -> Baz (T a)
--- so we have to strip off function argument types,
--- as well as the bit before the '=>' (which is always 
--- empty in interface files)
---
--- The parser ensures the type will have the right shape.
--- (e.g. see ParseUtil.checkInstType)
-
-get_head  (HsForAllTy (Just tvs) _ tau) = (tvs, get_head1 tau)
-get_head  tau                          = ([],  get_head1 tau)
-
-get_head1 (HsFunTy _ ty)               = get_head1 ty
-get_head1 (HsPredTy (HsClassP cls tys)) = (cls,tys)
-
-
 
 -----------------------------------------------------
 --     Loading Rules
@@ -628,7 +612,11 @@ lookupFixityRn name
       -- loadHomeInterface, and consulting the Ifaces that comes back
       -- from that, because the interface file for the Name might not
       -- have been loaded yet.  Why not?  Suppose you import module A,
-      -- which exports a function 'f', which is defined in module B.
+      -- which exports a function 'f', thus;
+      --        module CurrentModule where
+      --         import A( f )
+      --       module A( f ) where
+      --         import B( f )
       -- Then B isn't loaded right away (after all, it's possible that
       -- nothing from B will be used).  When we come across a use of
       -- 'f', we need to know its fixity, and it's then, and only