[GHC] #16314: Improve confusing error message with MINIMAL pragma

GHC ghc-devs at haskell.org
Wed Feb 13 02:36:16 UTC 2019


#16314: Improve confusing error message with MINIMAL pragma
-------------------------------------+-------------------------------------
           Reporter:  lerkok         |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.6.3
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I got bitten by this recently, and while I can see GHC's reasoning, I wish
 it told me something different and more useful.

 {{{#!hs
 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.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16314>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list