X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Ftypes%2FType.lhs;h=aa3cd077b05898deac0bfe17e3f09ef7cbc35121;hp=4bf54170c2fec4e94a5af0bf8ee47ec71f136386;hb=25f84fa7e4b84c3db5ba745a7881c009b778e0b1;hpb=d9236c265896d65ae4f1d4f4a240d8c0ffbce6f3 diff --git a/compiler/types/Type.lhs b/compiler/types/Type.lhs index 4bf5417..aa3cd07 100644 --- a/compiler/types/Type.lhs +++ b/compiler/types/Type.lhs @@ -415,8 +415,14 @@ splitNewTyConApp_maybe (FunTy arg res) = Just (funTyCon, [arg,res]) splitNewTyConApp_maybe other = Nothing newTyConInstRhs :: TyCon -> [Type] -> Type -newTyConInstRhs tycon tys = - let (tvs, ty) = newTyConRhs tycon in substTyWith tvs tys ty +-- Unwrap one 'layer' of newtype +-- Use the eta'd version if possible +newTyConInstRhs tycon tys + = ASSERT2( equalLength tvs tys1, ppr tycon $$ ppr tys $$ ppr tvs ) + mkAppTys (substTyWith tvs tys1 ty) tys2 + where + (tvs, ty) = newTyConEtadRhs tycon + (tys1, tys2) = splitAtList tvs tys \end{code}