Migrate cvs diff from fptools-assoc branch
[ghc-hetmet.git] / compiler / deSugar / Match.lhs
index 641c2ca..d793343 100644 (file)
@@ -305,7 +305,7 @@ matchCoercion :: [Id] -> Type -> [EquationInfo] -> DsM MatchResult
 matchCoercion (var:vars) ty (eqn1:eqns)
   = do { let CoPat co pat _ = firstPat eqn1
        ; var' <- newUniqueId (idName var) (hsPatType pat)
-       ; match_result <- match (var:vars) ty (map shift (eqn1:eqns))
+       ; match_result <- match (var':vars) ty (map shift (eqn1:eqns))
        ; rhs <- dsCoercion co (return (Var var))
        ; return (mkCoLetMatchResult (NonRec var' rhs) match_result) }
   where
@@ -745,6 +745,10 @@ sameGroup (PgN l1)   (PgN l2)   = True             -- Needs conditionals
 sameGroup (PgNpK l1) (PgNpK l2) = l1==l2       -- Order is significant
                                                -- See Note [Order of n+k]
 sameGroup (PgCo        t1)  (PgCo t2)  = t1 `coreEqType` t2
+       -- CoPats are in the same goup only if the type of the
+       -- enclosed pattern is the same. The patterns outside the CoPat
+       -- always have the same type, so this boils down to saying that
+       -- the two coercions are identical.
 sameGroup _          _          = False
  
 patGroup :: Pat Id -> PatGroup