Commit cc92a446 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Improve error message in deriving( Functor )

Fixes Trac #12163.  Pretty simple.
parent 7e7aeab2
......@@ -1415,12 +1415,19 @@ cond_stdOK Nothing permissive (_, rep_tc)
check_con :: DataCon -> Validity
check_con con
| not (isVanillaDataCon con)
= NotValid (badCon con (text "has existentials or constraints in its type"))
| not (null eq_spec)
= bad "is a GADT"
| not (null ex_tvs)
= bad "has existential type variables in its type"
| not (null theta)
= bad "has constraints in its type"
| not (permissive || all isTauTy (dataConOrigArgTys con))
= NotValid (badCon con (text "has a higher-rank type"))
= bad "has a higher-rank type"
| otherwise
= IsValid
where
(_, ex_tvs, eq_spec, theta, _, _) = dataConFullSig con
bad msg = NotValid (badCon con (text msg))
no_cons_why :: TyCon -> SDoc
no_cons_why rep_tc = quotes (pprSourceTyCon rep_tc) <+>
......
......@@ -4,7 +4,7 @@ GenCannotDoRep0_0.hs:6:14: warning:
GenCannotDoRep0_0.hs:13:45: error:
• Can't make a derived instance of ‘Generic Dynamic’:
Constructor ‘Dynamic’ has existentials or constraints in its type
Constructor ‘Dynamic’ has existential type variables in its type
Possible fix: use a standalone deriving declaration instead
• In the data declaration for ‘Dynamic’
......
GenCannotDoRep1_0.hs:9:49:
Can't make a derived instance of ‘Generic1 Dynamic’:
Constructor ‘Dynamic’ has existentials or constraints in its type
GenCannotDoRep1_0.hs:9:49: error:
Can't make a derived instance of ‘Generic1 Dynamic’:
Constructor ‘Dynamic’ has existential type variables in its type
Possible fix: use a standalone deriving declaration instead
In the data declaration for ‘Dynamic’
In the data declaration for ‘Dynamic’
tcfail086.hs:6:38:
Can't make a derived instance of ‘Eq Ex’:
Constructor ‘Ex’ has existentials or constraints in its type
tcfail086.hs:6:38: error:
Can't make a derived instance of ‘Eq Ex’:
Constructor ‘Ex’ has existential type variables in its type
Possible fix: use a standalone deriving declaration instead
In the data declaration for ‘Ex’
In the data declaration for ‘Ex’
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