Don't import FastString in HsVersions.h
[ghc-hetmet.git] / compiler / typecheck / TcGadt.lhs
index 6650bde..e45d6bd 100644 (file)
@@ -39,11 +39,9 @@ import Maybes
 import Control.Monad
 import Outputable
 import TcType
-
-#ifdef DEBUG
 import Unique
 import UniqFM
-#endif
+import FastString
 \end{code}
 
 
@@ -240,11 +238,15 @@ fixTvCoEnv in_scope env
       -- then use transitivity with the original coercion
 
 -----------------------------
+-- XXX Can we do this more nicely, by exploiting laziness?
+-- Or avoid needing it in the first place?
 fixTvSubstEnv :: InScopeSet -> TvSubstEnv -> TvSubstEnv
-fixTvSubstEnv in_scope env
-  = fixpt 
+fixTvSubstEnv in_scope env = f env
   where
-    fixpt = mapVarEnv (substTy (mkTvSubst in_scope fixpt)) env
+    f e = let e' = mapUFM (substTy (mkTvSubst in_scope e)) e
+          in if and $ eltsUFM $ intersectUFM_C tcEqType e e'
+             then e
+             else f e'
 
 ----------------------------
 tryToBind :: TyVarSet -> TyVar -> BindFlag
@@ -261,7 +263,6 @@ tryToBind tv_set tv | tv `elemVarSet` tv_set = BindMe
 %************************************************************************
 
 \begin{code}
-#ifdef DEBUG
 badReftElts :: InternalReft -> [(Unique, (Coercion,Type))]
 -- Return the BAD elements of the refinement
 -- Should be empty; used in asserions only
@@ -274,7 +275,6 @@ badReftElts env
                     | otherwise = False
        where
          (ty1,ty2) = coercionKind co
-#endif
 
 emptyInternalReft :: InternalReft
 emptyInternalReft = emptyVarEnv