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,393
    • Issues 4,393
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 379
    • Merge Requests 379
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #5095

Closed
Open
Opened Apr 05, 2011 by brunosoliveira@trac-brunosoliveira

Incoherent instance for Prelude type class accepted without incoherent instances option

If we create a new module allowing overlapping instances, flexible instances and undecidable instances we can define a function that selects an incoherent instance for a type class defined in the Prelude. Example:

> {-# OPTIONS -XFlexibleInstances -XOverlappingInstances -XUndecidableInstances #-}

> module Test where

> instance Show a => Eq a where
>   x == y =  length (show x) == length (show y)
>
> f :: Show a => a -> a -> Bool
> f x y = x == y
>
> p = f (3 :: Int) 4

The instance selected here (tested with GHC 7.0 and 6.12) is the one in this module, even if the instance Eq Int from the Prelude is more specific. If we try to reproduce a similar example using a module other than the Prelude, an incoherent instances error is reported. I believe that, for consistency the same should happen here.

Edited Mar 09, 2019 by Ian Lynagh <igloo@earth.li>
Assignee
Assign to
7.4.1
Milestone
7.4.1
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#5095