warning for cyclic unimplemented defaults
It's really nice how GHC warns when a class method is left out unimplemented. Alas, GHC does not warn if there's a default implementation that only works in case another method is defined.
Here's an example: The Num class allows either negate or '-' to be defined, providing default definitions for each in terms of the other. If a user leaves both undefined, then he gets himself a nice little tight-loop with no warnings. To break the cycle, the user should implement at least one of these. Thus, it would be really nice if GHC warned in such cases.
I'm guessing that GHC already has all the relevant information at hand when compiling an instance declaration, so I'm hoping it's not too much work to warn if there's such a cyclic dependency; just like it warns if the user leaves methods unimplemented.
Trac metadata
Trac field | Value |
---|---|
Version | 7.4.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |