Mark intentionally omitted type class instances
In GHCi I get
Prelude> 2+3::Char
<interactive>:2:2:
No instance for (Num Char)
arising from a use of `+'
Possible fix: add an instance declaration for (Num Char)
In the expression: 2 + 3 :: Char
In an equation for `it': it = 2 + 3 :: Char
In many cases users now actually try to implement the instance Num Char, but this is certainly not a good idea. I would like to tell the user whenever an instance is intentionally unimplemented and why it is missing. Like so
{-# NOINSTANCE Num Char where "There is no sound arithmetic on characters." #-}
The syntax after NOINSTANCE should be like in an instance declaration. It shall be treated like a type class instance, e.g. it shall be checked whether the same instance already exists, or whether it is orphan, or whether it is not Haskell 98, and it should require to enable according extensions like MultiParamTypeClasses. If on resolution a non-instance is chosen then the compiler should print the custom warning "There is no sound arithmetic on characters." instead of "probable fix: add instance".
Trac metadata
Trac field | Value |
---|---|
Version | 7.6.2 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |