Commit 4ff9f4f8 authored by simonpj's avatar simonpj
Browse files

[project @ 2004-05-06 12:28:41 by simonpj]

Improve error handling for deriving(Typeable)
parent 9ea0c515
...@@ -584,7 +584,7 @@ sideConditions ...@@ -584,7 +584,7 @@ sideConditions
(enumClassKey, cond_std `andCond` cond_isEnumeration), (enumClassKey, cond_std `andCond` cond_isEnumeration),
(ixClassKey, cond_std `andCond` (cond_isEnumeration `orCond` cond_isProduct)), (ixClassKey, cond_std `andCond` (cond_isEnumeration `orCond` cond_isProduct)),
(boundedClassKey, cond_std `andCond` (cond_isEnumeration `orCond` cond_isProduct)), (boundedClassKey, cond_std `andCond` (cond_isEnumeration `orCond` cond_isProduct)),
(typeableClassKey, cond_glaExts `andCond` cond_allTypeKind), (typeableClassKey, cond_glaExts `andCond` cond_typeableOK),
(dataClassKey, cond_glaExts `andCond` cond_std) (dataClassKey, cond_glaExts `andCond` cond_std)
] ]
...@@ -627,12 +627,17 @@ cond_isProduct (gla_exts, tycon) ...@@ -627,12 +627,17 @@ cond_isProduct (gla_exts, tycon)
where where
why = quotes (ppr tycon) <+> ptext SLIT("has more than one constructor") why = quotes (ppr tycon) <+> ptext SLIT("has more than one constructor")
cond_allTypeKind :: Condition cond_typeableOK :: Condition
cond_allTypeKind (gla_exts, tycon) -- OK for Typeable class
| all (isArgTypeKind . tyVarKind) (tyConTyVars tycon) = Nothing -- Currently: (a) args all of kind *
| otherwise = Just why -- (b) 7 or fewer args
cond_typeableOK (gla_exts, tycon)
| tyConArity tycon > 7 = Just too_many
| not (all (isArgTypeKind . tyVarKind) (tyConTyVars tycon)) = Just bad_kind
| otherwise = Nothing
where where
why = quotes (ppr tycon) <+> ptext SLIT("is parameterised over arguments of kind other than `*'") too_many = quotes (ppr tycon) <+> ptext SLIT("has too many arguments")
bad_kind = quotes (ppr tycon) <+> ptext SLIT("has arguments of kind other than `*'")
cond_glaExts :: Condition cond_glaExts :: Condition
cond_glaExts (gla_exts, tycon) | gla_exts = Nothing cond_glaExts (gla_exts, tycon) | gla_exts = Nothing
......
Supports Markdown
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