[project @ 1998-08-14 11:46:33 by sof]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcType.lhs
index 2944d90..1c0c193 100644 (file)
@@ -1,3 +1,8 @@
+%
+% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
+%
+\section[TcType]{Types used in the typechecker}
+
 \begin{code}
 module TcType (
   
@@ -36,33 +41,28 @@ module TcType (
 
 
 -- friends:
-import Type    ( Type, ThetaType, GenType(..), mkAppTy,
-                 tyVarsOfTypes, getTyVar_maybe, splitDictTy_maybe,
-                 splitForAllTys, splitRhoTy, isTyVarTy,
-                 mkForAllTys, instantiateTy
-               )
-import TyVar   ( TyVar, GenTyVar(..), TyVarSet, GenTyVarSet, 
-                 TyVarEnv, lookupTyVarEnv, addToTyVarEnv,
-                 emptyTyVarEnv, mkTyVarEnv, zipTyVarEnv,
-                 tyVarSetToList
-               )
+import Type            ( Type, ThetaType, GenType(..), mkAppTy,
+                         tyVarsOfTypes, splitDictTy_maybe,
+                         isTyVarTy, instantiateTy
+                       )
+import TyVar           ( TyVar, GenTyVar(..), GenTyVarSet, 
+                         TyVarEnv, lookupTyVarEnv, addToTyVarEnv,
+                         emptyTyVarEnv, zipTyVarEnv, tyVarSetToList
+                       )
 
 -- others:
-import Class   ( Class )
-import TyCon   ( isFunTyCon )
-import Kind    ( Kind )
-import TcKind  ( TcKind )
+import Class           ( Class )
+import TyCon           ( isFunTyCon )
+import Kind            ( Kind )
 import TcMonad
+import Name            ( changeUnique )
 
 import TysPrim         ( voidTy )
 
-import Name            ( NamedThing(..) )
 import Unique          ( Unique )
 import UniqFM          ( UniqFM )
-import Maybes          ( assocMaybe )
 import BasicTypes      ( unused )
-import Util            ( zipEqual, nOfThem )
-import Outputable
+import Util            ( nOfThem, panic )
 \end{code}
 
 
@@ -182,8 +182,13 @@ inst_sig_tyvar (TyVar _ kind name _)
 
     tcNewMutVar UnBound                `thenNF_Tc` \ box ->
        -- Was DontBind, but we've nuked that "optimisation"
+    let
+       name' = case name of
+                 Nothing -> Nothing
+                 Just n  -> Just (changeUnique n uniq)
+    in
 
-    returnNF_Tc (TyVar uniq kind name box)
+    returnNF_Tc (TyVar uniq kind name' box)
        -- We propagate the name of the sigature type variable
 \end{code}
 
@@ -234,6 +239,9 @@ tcInstSigType ty_to_inst
   where
     bind_fn = inst_sig_tyvar   -- Note: inst_sig_tyvar, not inst_tyvar
                                -- I don't think that can lead to strange error messages
+                               -- of the form can't match (T a) against (T a)
+                               -- See notes with inst_tyvar
+
     occ_fn env tyvar = case lookupTyVarEnv env tyvar of
                         Just ty -> returnNF_Tc ty
                         Nothing -> panic "tcInstType:2"-- (vcat [ppr ty_to_inst,