Haddock fixes
[ghc-hetmet.git] / compiler / types / FunDeps.lhs
index 170304c..0bea32f 100644 (file)
@@ -9,8 +9,8 @@ It's better to read it as: "if we know these, then we're going to know these"
 
 \begin{code}
 module FunDeps (
-       Equation, pprEquation,
-       oclose, grow, improveOne,
+       Equation, pprEquation, 
+       oclose, improveFromInstEnv, improveFromAnother,
        checkInstCoverage, checkFunDeps,
        pprFundeps
     ) where
@@ -132,44 +132,6 @@ oclose preds fixed_tvs
              ]
 \end{code}
 
-Note [Growing the tau-tvs using constraints]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-(grow preds tvs) is the result of extend the set of tyvars tvs
-                using all conceivable links from pred
-
-E.g. tvs = {a}, preds = {H [a] b, K (b,Int) c, Eq e}
-Then grow precs tvs = {a,b,c}
-
-All the type variables from an implicit parameter are added, whether or
-not they are mentioned in tvs; see Note [Implicit parameters and ambiguity] 
-in TcSimplify.
-
-See also Note [Ambiguity] in TcSimplify
-
-\begin{code}
-grow :: [PredType] -> TyVarSet -> TyVarSet
-grow preds fixed_tvs 
-  | null preds = fixed_tvs
-  | otherwise  = loop real_fixed_tvs
-  where
-       -- Add the implicit parameters; 
-       -- see Note [Implicit parameters and ambiguity] in TcSimplify
-    real_fixed_tvs = foldr unionVarSet fixed_tvs ip_tvs
-    loop fixed_tvs
-       | new_fixed_tvs `subVarSet` fixed_tvs = fixed_tvs
-       | otherwise                           = loop new_fixed_tvs
-       where
-         new_fixed_tvs = foldl extend fixed_tvs non_ip_tvs
-
-    extend fixed_tvs pred_tvs 
-       | fixed_tvs `intersectsVarSet` pred_tvs = fixed_tvs `unionVarSet` pred_tvs
-       | otherwise                             = fixed_tvs
-
-    (ip_tvs, non_ip_tvs) = partitionWith get_ip preds
-    get_ip (IParam _ ty) = Left (tyVarsOfType ty)
-    get_ip other         = Right (tyVarsOfPred other)
-\end{code}
     
 %************************************************************************
 %*                                                                     *
@@ -238,6 +200,21 @@ NOTA BENE:
 \begin{code}
 type Pred_Loc = (PredType, SDoc)       -- SDoc says where the Pred comes from
 
+improveFromInstEnv :: (Class -> [Instance]) 
+                     -> Pred_Loc 
+                     -> [(Equation,Pred_Loc,Pred_Loc)]
+-- Improvement from top-level instances 
+improveFromInstEnv _inst_env pred 
+  = improveOne _inst_env pred []        -- TODO: Refactor to directly use instance_eqnd? 
+
+improveFromAnother :: Pred_Loc 
+                   -> Pred_Loc
+                   -> [(Equation,Pred_Loc,Pred_Loc)] 
+-- Improvement from another local (given or wanted) constraint
+improveFromAnother pred1 pred2 
+  = improveOne (\_ -> []) pred1 [pred2] -- TODO: Refactor to directly use pairwise_eqns?
+
+
 improveOne :: (Class -> [Instance])            -- Gives instances for given class
           -> Pred_Loc                          -- Do improvement triggered by this
           -> [Pred_Loc]                        -- Current constraints 
@@ -294,8 +271,9 @@ improveOne inst_env pred@(ClassP cls tys, _) preds
        , not (instanceCantMatch inst_tcs trimmed_tcs)
        , eqn <- checkClsFD qtvs fd cls_tvs tys_inst tys
        , let p_inst = (mkClassPred cls tys_inst, 
-                       ptext (sLit "arising from the instance declaration at")
-                       <+> ppr (getSrcLoc ispec))
+                       sep [ ptext (sLit "arising from the dependency") <+> quotes (pprFunDep fd)
+                           , ptext (sLit "in the instance declaration at") 
+                                 <+> ppr (getSrcLoc ispec)])
        ]
 
 improveOne _ _ _