Eta-expand newtype coercions in External Core
authorTim Chevalier <chevalier@alum.wellesley.edu>
Mon, 14 Apr 2008 03:16:54 +0000 (03:16 +0000)
committerTim Chevalier <chevalier@alum.wellesley.edu>
Mon, 14 Apr 2008 03:16:54 +0000 (03:16 +0000)
Typechecking External Core is easier if we eta-expand axioms
in newtype declarations. For a fuller explanation, see:
http://www.haskell.org/pipermail/cvs-ghc/2008-April/041948.html

compiler/coreSyn/MkExternalCore.lhs

index 337b21a..5ca4345 100644 (file)
@@ -95,7 +95,11 @@ collect_tdefs tcon tdefs
         -- See Note [Newtype coercions] in 
         -- types/TyCon
         Just (arity,coKindFun) | (l,r) <- (coKindFun $ map mkTyVarTy vs) -> 
         -- See Note [Newtype coercions] in 
         -- types/TyCon
         Just (arity,coKindFun) | (l,r) <- (coKindFun $ map mkTyVarTy vs) -> 
-            (vs,l,r) where vs = take arity tyvars
+             -- Here we eta-expand the newtype coercion,
+             -- which makes the ext-core typechecker somewhat simpler.
+            (tyvars,mkAppTys l extraVs,mkAppTys r extraVs)
+               where (vs, extraVs) = (take arity tyvars,
+                        map mkTyVarTy $ drop arity tyvars)
         Nothing -> pprPanic "MkExternalCore: coercion tcon lacks a kind fun"
                      (ppr tcon)
 
         Nothing -> pprPanic "MkExternalCore: coercion tcon lacks a kind fun"
                      (ppr tcon)