Ambiguous type var with DefaultSignatures and FunctionalDependencies
Consider:
{-# LANGUAGE DefaultSignatures, FunctionalDependencies, ScopedTypeVariables #-}
class Foo a b where
foo :: a -> b -> Int
class Bar a b | b -> a where
get :: b -> a
bar :: b -> Int
default bar :: Foo a b => b -> Int
bar b = foo (get b :: a) b
This works fine with ghc 7.10.3 (even without the explicit :: a type spec), but with 8.0.1, produces:
- Could not deduce (Foo a0 b)
from the context: Foo a b
bound by the type signature for:
bar :: Foo a b => b -> Int
at t.hs:6:3-17
The type variable `a0' is ambiguous
- In the ambiguity check for `bar'
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
When checking the class method:
bar :: forall a b. Bar a b => b -> Int
In the class declaration for `Bar'
Not sure if this is intentional or some good way to get around it, but I couldn't find anything related to it in the release notes or any similar looking bugs. (Real-life case: https://github.com/dylex/postgresql-typed/blob/master/Database/PostgreSQL/Typed/Dynamic.hs#L48 )
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |