[GHC] #13061: Incorrect constraints given single flexible undecidable instance
GHC
ghc-devs at haskell.org
Tue Jan 3 20:47:09 UTC 2017
#13061: Incorrect constraints given single flexible undecidable instance
-------------------------------------+-------------------------------------
Reporter: JCarr | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.0.1
checker) | Keywords: Constraint,
Resolution: | UndecidableInstances,
| FlexibleInstances
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Description changed by JCarr:
@@ -14,1 +14,3 @@
- f will have type Eq a => a -> a -> Bool
+ f will have type Eq a => a -> a -> Bool.
+ A function of type A a => ... will always be rejected unless Eq is also
+ included.
@@ -21,3 +23,1 @@
- Then f will have the type A a => a -> a -> Bool.
- A function of type A a => ... will always be rejected unless Eq is also
- included
+ Then f will have the correct type A a => a -> a -> Bool.
New description:
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
{{{#!hs
{-# 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.
A function of type A a => ... will always be rejected unless Eq is also
included.
If we add:
{{{#!hs
instance A Int where
f = id
}}}
Then f will have the correct type A a => a -> a -> Bool.
--
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13061#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list