X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Ftypes%2FTyCon.lhs;h=befc4e6f938bfe3c0d7c3b27e002aa9bc3b23ad0;hp=dc7e2d3e327caff4534d6a10572fd045ebfe9a83;hb=da2e18b9ab29131bda1ac8e3962dc50b635589a5;hpb=eb6e1243d28a5acd967b981893a6cc96f145207f diff --git a/compiler/types/TyCon.lhs b/compiler/types/TyCon.lhs index dc7e2d3..befc4e6 100644 --- a/compiler/types/TyCon.lhs +++ b/compiler/types/TyCon.lhs @@ -39,6 +39,7 @@ module TyCon( isCoercionTyCon, isCoercionTyCon_maybe, isForeignTyCon, + isInjectiveTyCon, isDataTyCon, isProductTyCon, isEnumerationTyCon, isNewTyCon, isAbstractTyCon, isOpenTyCon, isUnLiftedTyCon, @@ -815,6 +816,17 @@ isOpenTyCon (SynTyCon {synTcRhs = OpenSynTyCon {}}) = True isOpenTyCon (AlgTyCon {algTcRhs = OpenTyCon {}}) = True isOpenTyCon _ = False +-- | Injective 'TyCon's can be decomposed, so that +-- T ty1 ~ T ty2 => ty1 ~ ty2 +isInjectiveTyCon :: TyCon -> Bool +isInjectiveTyCon tc = not (isSynTyCon tc) + -- Ultimately we may have injective associated types + -- in which case this test will become more interesting + -- + -- It'd be unusual to call isInjectiveTyCon on a regular H98 + -- type synonym, because you should probably have expanded it first + -- But regardless, it's not injective! + -- | Extract the mapping from 'TyVar' indexes to indexes in the corresponding family -- argument lists form an open 'TyCon' of any sort, if the given 'TyCon' is indeed -- such a beast and that information is available