From 71d2bf9206b94d45570dc20de1a5ded12d493708 Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Fri, 4 May 2007 11:03:01 +0000 Subject: [PATCH] isDataTyCon should be False for all type families, even data type families isDataTyCon advertises that it's true of "data types that are definitely represented by heap-allocated constructors. These are srcutinised by Core-level @case@ expressions, and they get info tables allocated for them." Type-family TyCons never have this property, not even data type families. It's the *instance* TyCons that do. I hope that this change does not break anything that somehow relied on the old (wrong) semantics. --- compiler/typecheck/TcGadt.lhs | 20 -------------------- compiler/types/TyCon.lhs | 7 ++++++- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/compiler/typecheck/TcGadt.lhs b/compiler/typecheck/TcGadt.lhs index 3761c68..4cd7e00 100644 --- a/compiler/typecheck/TcGadt.lhs +++ b/compiler/typecheck/TcGadt.lhs @@ -14,7 +14,6 @@ module TcGadt ( Refinement, emptyRefinement, isEmptyRefinement, gadtRefine, refineType, refinePred, refineResType, - dataConCanMatch, tcUnifyTys, BindFlag(..) ) where @@ -242,29 +241,10 @@ fixTvSubstEnv in_scope env fixpt = mapVarEnv (substTy (mkTvSubst in_scope fixpt)) env ---------------------------- -dataConCanMatch :: [Type] -> DataCon -> Bool --- Returns True iff the data con can match a scrutinee of type (T tys) --- where T is the type constructor for the data con --- --- Instantiate the equations and try to unify them -dataConCanMatch tys con - | null eq_spec = True -- Common - | all isTyVarTy tys = True -- Also common - | otherwise - = isJust (tcUnifyTys (\tv -> BindMe) - (map (substTyVar subst . fst) eq_spec) - (map snd eq_spec)) - where - dc_tvs = dataConUnivTyVars con - eq_spec = dataConEqSpec con - subst = zipTopTvSubst dc_tvs tys - ----------------------------- tryToBind :: TyVarSet -> TyVar -> BindFlag tryToBind tv_set tv | tv `elemVarSet` tv_set = BindMe | otherwise = AvoidMe - \end{code} diff --git a/compiler/types/TyCon.lhs b/compiler/types/TyCon.lhs index 50d76cf..90ac71c 100644 --- a/compiler/types/TyCon.lhs +++ b/compiler/types/TyCon.lhs @@ -616,9 +616,14 @@ isDataTyCon :: TyCon -> Bool -- True for all @data@ types -- False for newtypes -- unboxed tuples +-- type families +-- +-- NB: for a data type family, T, only the *instance* tycons are +-- get an info table etc. The family tycon does not. +-- Hence False for OpenTyCon isDataTyCon tc@(AlgTyCon {algTcRhs = rhs}) = case rhs of - OpenTyCon {} -> not (otIsNewtype rhs) + OpenTyCon {} -> False DataTyCon {} -> True NewTyCon {} -> False AbstractTyCon -> False -- We don't know, so return False -- 1.7.10.4