X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FbasicTypes%2FDataCon.lhs;h=3de990512874051f580f4c7c54f216eefd284d91;hb=a1899edb87b3192f192980f392680df05f50f104;hp=f87397734370559665b9fde9a3888a1f3933cb34;hpb=4d9b47b2efef6490ae8659431a50b8f944fda08f;p=ghc-hetmet.git diff --git a/compiler/basicTypes/DataCon.lhs b/compiler/basicTypes/DataCon.lhs index f873977..3de9905 100644 --- a/compiler/basicTypes/DataCon.lhs +++ b/compiler/basicTypes/DataCon.lhs @@ -38,7 +38,8 @@ import Type ( Type, ThetaType, import Coercion ( isEqPred, mkEqPred ) import TyCon ( TyCon, FieldLabel, tyConDataCons, isProductTyCon, isTupleTyCon, isUnboxedTupleTyCon, - isNewTyCon, isRecursiveTyCon ) + isNewTyCon, isClosedNewTyCon, isRecursiveTyCon, + tyConFamInst_maybe ) import Class ( Class, classTyCon ) import Name ( Name, NamedThing(..), nameUnique, mkSysTvName, mkSystemName ) import Var ( TyVar, CoVar, Id, mkTyVar, tyVarKind, setVarUnique, @@ -459,7 +460,8 @@ mkDataCon name declared_infix dcStupidTheta = stupid_theta, dcTheta = theta, dcOrigArgTys = orig_arg_tys, dcTyCon = tycon, dcRepArgTys = rep_arg_tys, - dcStrictMarks = arg_stricts, dcRepStrictness = rep_arg_stricts, + dcStrictMarks = arg_stricts, + dcRepStrictness = rep_arg_stricts, dcFields = fields, dcTag = tag, dcRepType = ty, dcIds = ids } @@ -606,6 +608,8 @@ dataConUserType :: DataCon -> Type -- T :: forall a. a -> T [a] -- rather than -- T :: forall b. forall a. (a=[b]) => a -> T b +-- NB: If the constructor is part of a data instance, the result type +-- mentions the family tycon, not the internal one. dataConUserType (MkData { dcUnivTyVars = univ_tvs, dcExTyVars = ex_tvs, dcEqSpec = eq_spec, dcTheta = theta, dcOrigArgTys = arg_tys, @@ -613,7 +617,9 @@ dataConUserType (MkData { dcUnivTyVars = univ_tvs, = mkForAllTys ((univ_tvs `minusList` map fst eq_spec) ++ ex_tvs) $ mkFunTys (mkPredTys theta) $ mkFunTys arg_tys $ - mkTyConApp tycon (map (substTyVar subst) univ_tvs) + case tyConFamInst_maybe tycon of + Nothing -> mkTyConApp tycon (map (substTyVar subst) univ_tvs) + Just (ftc, insttys) -> mkTyConApp ftc insttys -- data instance where subst = mkTopTvSubst eq_spec @@ -722,9 +728,10 @@ splitProductType str ty deepSplitProductType_maybe ty = do { (res@(tycon, tycon_args, _, _)) <- splitProductType_maybe ty ; let {result - | isNewTyCon tycon && not (isRecursiveTyCon tycon) + | isClosedNewTyCon tycon && not (isRecursiveTyCon tycon) = deepSplitProductType_maybe (newTyConInstRhs tycon tycon_args) - | isNewTyCon tycon = Nothing -- cannot unbox through recursive newtypes + | isNewTyCon tycon = Nothing -- cannot unbox through recursive + -- newtypes nor through families | otherwise = Just res} ; result }