fix for Simple9
authorTom Schrijvers <tom.schrijvers@cs.kuleuven.be>
Thu, 6 Sep 2007 17:17:03 +0000 (17:17 +0000)
committerTom Schrijvers <tom.schrijvers@cs.kuleuven.be>
Thu, 6 Sep 2007 17:17:03 +0000 (17:17 +0000)
No longer include non-indexed arguments
in lookup of matching type function clause.
By including non-indexed (additional) arguments,
the lookup always fails.

compiler/typecheck/TcTyFuns.lhs

index fc19061..f8bf40e 100644 (file)
@@ -68,15 +68,19 @@ tcUnfoldSynFamInst (TyConApp tycon tys)
   | not (isOpenSynTyCon tycon)     -- unfold *only* _synonym_ family instances
   = return Nothing
   | otherwise
-  = do { maybeFamInst <- tcLookupFamInst tycon tys
+  = do { -- we only use the indexing arguments for matching, not the additional ones
+        maybeFamInst <- tcLookupFamInst tycon idxTys
        ; case maybeFamInst of
            Nothing                -> return Nothing
-           Just (rep_tc, rep_tys) -> return $ Just (mkTyConApp rep_tc rep_tys,
-                                                   mkTyConApp coe_tc rep_tys)
+           Just (rep_tc, rep_tys) -> return $ Just (mkTyConApp rep_tc (rep_tys ++ restTys),
+                                                   mkTyConApp coe_tc (rep_tys ++ restTys))
              where
                coe_tc = expectJust "TcTyFun.tcUnfoldSynFamInst" 
                                    (tyConFamilyCoercion_maybe rep_tc)
        }
+    where
+        n                = tyConArity tycon
+        (idxTys, restTys) = splitAt n tys
 tcUnfoldSynFamInst _other = return Nothing
 \end{code}