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,333
    • Issues 4,333
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 371
    • Merge Requests 371
  • 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
  • #1608

Closed
Open
Opened Aug 10, 2007 by Simon Peyton Jones@simonpjDeveloper

Newtype deriving error messages coming out too late

Consider this

newtype Ego a = Ego a deriving (Ord)

f :: Ord a => Ego a -> Ego a -> Bool
f e1 e2 = e1 < e2

GHC 6.7 reports an error like this:

    Could not deduce (Eq (Ego a)) from the context (Ord a)
      arising from a use of `<' at Foo10.hs:6:10-16
    In the expression: e1 < e2
    In the definition of `f': f e1 e2 = e1 < e2

This error should have come when you gave the instance decl. The reason is that GHC's newtype deriving is generating an instance like

instance Eq (Ego a) => Ord (Ego a)

It would make more sense to report the missing instance for Eq right there, rather than abstracting over it.

Thanks to Dougal Stanton for pointing this out: http://www.haskell.org/pipermail/haskell-cafe/2007-August/030224.html

Trac metadata
Trac field Value
Version 6.6.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
Assignee
Assign to
6.10 branch
Milestone
6.10 branch
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#1608