id summary reporter owner description type status priority milestone component version resolution keywords cc os architecture failure testcase blockedby blocking related differential
4894 Missing improvement for fun. deps. diatchki "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.
" feature request new normal ⊥ Compiler (Type checker) 7.1 dimitris@… mikhail.vorozhtsov@… Unknown/Multiple Unknown/Multiple None/Unknown