Skip to content

QuantifiedConstraints ignore FunctionalDependencies

The following code fails to compile:

{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE FunctionalDependencies #-}

class C a b | a -> b where
  foo :: a -> b

bar :: (forall a. C (f a) Int) => f a -> String
bar = show . foo
• Could not deduce (Show a0) arising from a use of ‘show’
...
The type variable ‘a0’ is ambiguous


• Could not deduce (C (f a) a0) arising from a use of ‘foo’
...
The type variable ‘a0’ is ambiguous

Yet it ought to work, since this is perfectly fine with top-level instances:

instance C [a] Int where ...

baz :: [a] -> String
baz = show . foo
Edited by aaronvargo
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information