Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,827
    • Issues 4,827
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 441
    • Merge requests 441
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #13061

Closed
Open
Created Jan 03, 2017 by JCarr@trac-JCarr

Incorrect constraints given single flexible undecidable instance.

If a class has an instance in the form F a => G a in its file, and no other instances, then the functions in G a will have the constraint F a, rather than G a.

Example file

{-# LANGUAGE FlexibleInstances, UndecidableInstances #-}
class A a where
    f :: a -> a
instance {-# OVERLAPPABLE #-} Eq a => A a where
    f = id

f will have type Eq a => a -> a -> Bool. Consider the functions

g, h, i :: A a => a -> a
g = f
h = let f' = f in f
i = f' where
    f' = f

h and i will both fail to typecheck.

If we add:

instance A Int where
    f = id

Then f will have the correct type A a => a -> a -> Bool.

Edited Mar 10, 2019 by JCarr
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking