X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypes%2FType.lhs;h=cf38146eb10d59b2c7b16691d72fdd35dba5fab0;hb=1ae354e107715a9e3fd4e2d67b61f868c090e4ae;hp=79a561a60c62541429afd34f9c0309165fc78f4c;hpb=4179e02ec7ec7aea79273cdcc166123c2ddd2063;p=ghc-hetmet.git diff --git a/compiler/types/Type.lhs b/compiler/types/Type.lhs index 79a561a..cf38146 100644 --- a/compiler/types/Type.lhs +++ b/compiler/types/Type.lhs @@ -44,7 +44,7 @@ module Type ( newTyConInstRhs, -- (Type families) - tyFamInsts, + tyFamInsts, predFamInsts, -- (Source types) mkPredTy, mkPredTys, mkFamilyTyConApp, @@ -887,6 +887,14 @@ tyFamInsts (TyConApp tc tys) tyFamInsts (FunTy ty1 ty2) = tyFamInsts ty1 ++ tyFamInsts ty2 tyFamInsts (AppTy ty1 ty2) = tyFamInsts ty1 ++ tyFamInsts ty2 tyFamInsts (ForAllTy _ ty) = tyFamInsts ty +tyFamInsts (PredTy pty) = predFamInsts pty + +-- | Finds type family instances occuring in a predicate type after expanding +-- synonyms. +predFamInsts :: PredType -> [(TyCon, [Type])] +predFamInsts (ClassP _cla tys) = concat (map tyFamInsts tys) +predFamInsts (IParam _ ty) = tyFamInsts ty +predFamInsts (EqPred ty1 ty2) = tyFamInsts ty1 ++ tyFamInsts ty2 \end{code} @@ -1147,14 +1155,16 @@ coreEqType t1 t2 \begin{code} tcEqType :: Type -> Type -> Bool --- ^ Type equality on source types. Does not look through @newtypes@ or 'PredType's +-- ^ Type equality on source types. Does not look through @newtypes@ or +-- 'PredType's, but it does look through type synonyms. tcEqType t1 t2 = isEqual $ cmpType t1 t2 tcEqTypes :: [Type] -> [Type] -> Bool tcEqTypes tys1 tys2 = isEqual $ cmpTypes tys1 tys2 tcCmpType :: Type -> Type -> Ordering --- ^ Type ordering on source types. Does not look through @newtypes@ or 'PredType's +-- ^ Type ordering on source types. Does not look through @newtypes@ or +-- 'PredType's, but it does look through type synonyms. tcCmpType t1 t2 = cmpType t1 t2 tcCmpTypes :: [Type] -> [Type] -> Ordering