Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,268
    • Issues 4,268
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 408
    • Merge Requests 408
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16314

Closed
Open
Opened Feb 13, 2019 by Levent Erkök@LeventErkokReporter

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
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#16314