Commit 1a77fd71 authored by chak@cse.unsw.edu.au.'s avatar chak@cse.unsw.edu.au.
Browse files

Type synonym families may be nullary

parent 432b9c93
......@@ -926,25 +926,17 @@ rnFamily :: TyClDecl RdrName
rnFamily (tydecl@TyFamily {tcdFlavour = flavour,
tcdLName = tycon, tcdTyVars = tyvars})
bindIdxVars =
do { checkM (isDataFlavour flavour -- for synonyms,
|| not (null tyvars)) $ addErr needOneIdx -- no. of indexes >= 1
; bindIdxVars (family_doc tycon) tyvars $ \tyvars' -> do {
do { bindIdxVars (family_doc tycon) tyvars $ \tyvars' -> do {
; tycon' <- lookupLocatedTopBndrRn tycon
; return (TyFamily {tcdFlavour = flavour, tcdLName = tycon',
tcdTyVars = tyvars', tcdKind = tcdKind tydecl},
emptyFVs)
} }
where
isDataFlavour DataFamily = True
isDataFlavour _ = False
rnFamily d _ = pprPanic "rnFamily" (ppr d)
family_doc :: Located RdrName -> SDoc
family_doc tycon = text "In the family declaration for" <+> quotes (ppr tycon)
needOneIdx :: SDoc
needOneIdx = text "Type family declarations requires at least one type index"
-- Rename associated type declarations (in classes)
--
-- * This can be family declarations and (default) type instances
......
......@@ -693,9 +693,6 @@ tcTyClDecl1 _calc_isrec
; idx_tys <- doptM Opt_TypeFamilies
; checkTc idx_tys $ badFamInstDecl tc_name
-- Check for no type indices
; checkTc (not (null tvs)) (noIndexTypes tc_name)
; tycon <- buildSynTyCon tc_name tvs' (OpenSynTyCon kind Nothing) kind Nothing
; return [ATyCon tycon]
}
......@@ -714,9 +711,6 @@ tcTyClDecl1 _calc_isrec
; idx_tys <- doptM Opt_TypeFamilies
; checkTc idx_tys $ badFamInstDecl tc_name
-- Check for no type indices
; checkTc (not (null tvs)) (noIndexTypes tc_name)
; tycon <- buildAlgTyCon tc_name final_tvs []
mkOpenDataTyConRhs Recursive False True Nothing
; return [ATyCon tycon]
......@@ -1500,11 +1494,6 @@ badSigTyDecl tc_name
quotes (ppr tc_name)
, nest 2 (parens $ ptext (sLit "Use -XKindSignatures to allow kind signatures")) ]
noIndexTypes :: Name -> SDoc
noIndexTypes tc_name
= ptext (sLit "Type family constructor") <+> quotes (ppr tc_name)
<+> ptext (sLit "must have at least one type index parameter")
badFamInstDecl :: Outputable a => a -> SDoc
badFamInstDecl tc_name
= vcat [ ptext (sLit "Illegal family instance for") <+>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment