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,332
    • Issues 4,332
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 363
    • Merge Requests 363
  • 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
  • #446

Closed
Open
Opened Aug 31, 2005 by greenrd@trac-greenrd

ghc is confused about instances of Ord

When I compile the attached file _without_ -fallow-incoherent-instances 
on ghc 6.4 on Fedora Core Linux, I receive the following errors: 
 
PartialOrder.hs:19:0: 
    Overlapping instances for PartialOrder a 
      arising from the superclasses of an instance declaration at 
PartialOrder.hs:19:0 
    Matching instances: 
      PartialOrder.hs:11:0: instance (Ord a) => PartialOrder a 
      PartialOrder.hs:19:0: instance PartialOrder (LineList a) 
    (The choice depends on the instantiation of `a' 
     Use -fallow-incoherent-instances to use the first choice above) 
    In the instance declaration for `PartialOrder (LineList a)' 
 
PartialOrder.hs:20:53: 
    Overlapping instances for PartialOrder a 
      arising from use of `lte' at PartialOrder.hs:20:53-55 
    Matching instances: 
      PartialOrder.hs:11:0: instance (Ord a) => PartialOrder a 
      PartialOrder.hs:19:0: instance PartialOrder (LineList a) 
    (The choice depends on the instantiation of `a' 
     Use -fallow-incoherent-instances to use the first choice above) 
    In the first argument of `zipWith', namely `lte' 
    In the first argument of `and', namely `(zipWith lte c d)' 
    In the definition of `lte': 
        lte (LineList c) (LineList d) = and (zipWith lte c d) 
 
However, when I compile it _with_ -fallow-incoherent-instances, I 
receive _these_ errors: 
 
PartialOrder.hs:19:0: 
    No instance for (Ord a) 
      arising from the superclasses of an instance declaration at 
PartialOrder.hs:19:0 
    Probable fix: add (Ord a) to the instance declaration superclass 
context 
    In the instance declaration for `PartialOrder (LineList a)' 
 
PartialOrder.hs:20:53: 
    Could not deduce (Ord a) 
      from the context (PartialOrder (LineList a), Eq (LineList a)) 
      arising from use of `lte' at PartialOrder.hs:20:53-55 
    Probable fix: add (Ord a) to the class or instance method `lte' 
    In the first argument of `zipWith', namely `lte' 
    In the first argument of `and', namely `(zipWith lte c d)' 
    In the definition of `lte': 
        lte (LineList c) (LineList d) = and (zipWith lte c d) 
 
So in the _first_ compilation run, ghc is suggesting that an instance of 
Ord a (which I believe is a figment of its imagination) collides; but in the 
_second_ compilation run, it complains that it can't _find_ the instance for 
Ord a. Surely an inconsistency. 
Trac metadata
Trac field Value
Version 6.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution ResolvedInvalid
Component Compiler (Type checker)
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#446