#4894: Missing improvement for fun. deps.
---------------------------------+------------------------------------------
Reporter: diatchki | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler (Type checker)
Version: 7.1 | Keywords:
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
The problem is illustrated by the following example:
{{{
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
class F a b | a -> b
f :: (F a b, F a c) => a -> b -> c
f _ = id
Results in the following error:
Could not deduce (b ~ c)
from the context (F a b, F a c)
bound by the type signature for f :: (F a b, F a c) => a -> b -> c
at bug.hs:6:1-8
`b' is a rigid type variable bound by
the type signature for f :: (F a b, F a c) => a -> b -> c
at bug.hs:6:1
`c' is a rigid type variable bound by
the type signature for f :: (F a b, F a c) => a -> b -> c
at bug.hs:6:1
Expected type: b -> c
Actual type: b -> b
In the expression: id
In an equation for `f': f _ = id
}}}
The issue seems to be related to Note [When improvement happens] in module
TcInteract. It states that two "givens" do not interact for the purposes
of improvement.
As far as I understand, the correct behavior should be to generate a new
given equality, justified by the functional dependency on the class.
This is also related to bug #1241: in order to justify an improvement by
functional dependency, we have to check that all instances are consistent
with the dependency. Otherwise, the above function would turn into an
"unsafe cast" function.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4894>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs