Fix up yesterdays commit to TcSimplify; fixes broken HEAD
[ghc-hetmet.git] / compiler / typecheck / TcSimplify.lhs
index 182a7c5..451e3b1 100644 (file)
@@ -657,7 +657,7 @@ tcSimplifyInfer
        :: SDoc
        -> TcTyVarSet           -- fv(T); type vars
        -> [Inst]               -- Wanted
        :: SDoc
        -> TcTyVarSet           -- fv(T); type vars
        -> [Inst]               -- Wanted
-       -> TcM ([TcTyVar],      -- Tyvars to quantify (zonked)
+       -> TcM ([TcTyVar],      -- Tyvars to quantify (zonked and quantified)
                [Inst],         -- Dict Ids that must be bound here (zonked)
                TcDictBinds)    -- Bindings
        -- Any free (escaping) Insts are tossed into the environment
                [Inst],         -- Dict Ids that must be bound here (zonked)
                TcDictBinds)    -- Bindings
        -- Any free (escaping) Insts are tossed into the environment
@@ -848,6 +848,7 @@ bindIrredsR loc qtvs co_vars reft givens irreds
   | otherwise
   = do { let givens' = filter isDict givens
                -- The givens can include methods
   | otherwise
   = do { let givens' = filter isDict givens
                -- The givens can include methods
+               -- See Note [Pruning the givens in an implication constraint]
 
           -- If there are no 'givens', then it's safe to 
           -- partition the 'wanteds' by their qtvs, thereby trimming irreds
 
           -- If there are no 'givens', then it's safe to 
           -- partition the 'wanteds' by their qtvs, thereby trimming irreds
@@ -1171,7 +1172,7 @@ tcSimplifyRestricted      -- Used for restricted binding groups
        -> [Name]               -- Things bound in this group
        -> TcTyVarSet           -- Free in the type of the RHSs
        -> [Inst]               -- Free in the RHSs
        -> [Name]               -- Things bound in this group
        -> TcTyVarSet           -- Free in the type of the RHSs
        -> [Inst]               -- Free in the RHSs
-       -> TcM ([TyVar],        -- Tyvars to quantify (zonked)
+       -> TcM ([TyVar],        -- Tyvars to quantify (zonked and quantified)
                TcDictBinds)    -- Bindings
        -- tcSimpifyRestricted returns no constraints to
        -- quantify over; by definition there are none.
                TcDictBinds)    -- Bindings
        -- tcSimpifyRestricted returns no constraints to
        -- quantify over; by definition there are none.
@@ -1876,6 +1877,20 @@ We can satisfy the (C Int) from the superclass of D, so we don't want
 to float the (C Int) out, even though it mentions no type variable in
 the constraints!
 
 to float the (C Int) out, even though it mentions no type variable in
 the constraints!
 
+Note [Pruning the givens in an implication constraint]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Suppose we are about to form the implication constraint
+       forall tvs.  Eq a => Ord b
+The (Eq a) cannot contribute to the (Ord b), because it has no access to
+the type variable 'b'.  So we could filter out the (Eq a) from the givens.
+
+Doing so would be a bit tidier, but all the implication constraints get
+simplified away by the optimiser, so it's no great win.   So I don't take
+advantage of that at the moment.
+
+If you do, BE CAREFUL of wobbly type variables.
+
+
 %************************************************************************
 %*                                                                     *
                Avails and AvailHow: the pool of evidence
 %************************************************************************
 %*                                                                     *
                Avails and AvailHow: the pool of evidence