[GHC] #12473: Ambiguous type var with DefaultSignatures and FunctionalDependencies
GHC
ghc-devs at haskell.org
Sun Aug 7 15:57:24 UTC 2016
#12473: Ambiguous type var with DefaultSignatures and FunctionalDependencies
-------------------------------------+-------------------------------------
Reporter: dylex | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
(Type checker) |
Keywords: | 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:
-------------------------------------+-------------------------------------
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 )
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12473>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list