Superclass functional dependencies are ignored during instance selection
The following example compiles with ghc-6.12.3, but not with ghc-7.0.0.20100924:
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
module Ambiguity where
class C1 a b | b -> a
class (C1 a b) => C2 a b where
foo :: b -> b
data A = A
data B = B
instance C1 A B
instance C2 A B
-- this is accepted by both 6.12.3 and 7
runFoo :: C2 a b => b -> b
runFoo = foo
-- this is accepted by 6.12.3, but not by 7
runFoo2 :: B -> B
runFoo2 = foo
A straightforward fix is to add the b -> a fundep to the C2 class as well.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |