Improve confusing error message with MINIMAL pragma
I got bitten by this recently, and while I can see GHC's reasoning, I wish it told me something different and more useful.
class X a where
foo :: a
{-# MINIMAL foo #-}
foo = undefined
instance X Int
For this program, ghc says:
GHCi, version 8.6.3: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( a.hs, interpreted )
a.hs:7:10: warning: [-Wmissing-methods]
• No explicit implementation for
‘foo’
• In the instance declaration for ‘X Int’
|
7 | instance X Int
| ^^^^^
This is arguably "correct", since I made foo
part of MINIMAL
; but it's very confusing, because I know I added a default definition.
I wish GHC instead said something like:
You made `foo` MINIMAL, but also gave an explicit definition for it.
I can see the logic behind the current error message, but it was rather confusing. The background is that my class had many other methods and a MINIMAL
pragma. Much later I realized I could give a default definition of one of those methods but I forgot to remove it from the MINIMAL
list. So, I had to puzzle a while at the error messages that were coming from far away modules that had nothing to do with the class definition itself.
This is not a showstopper by any means, but unless there are good reasons to do otherwise, it would be nice to get a warning right where the class is defined, as opposed to where it is instantiated.
Trac metadata
Trac field | Value |
---|---|
Version | 8.6.3 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |