Hi guys,<br><br>We are having trouble with the following program that uses type families:<br><br>> class Blah f a where<br>> blah :: a -> T f f a<br> <br>> class A f where<br>> type T f :: (* -> *) -> * -> *<br>
<br>the following function does not type:<br><br>> wrapper :: forall a f . Blah f a => a -> T f f a<br>> wrapper x = blah x<br><br>GHC gives the error:<br><br> Couldn't match expected type `T f1 f1 a'<br>
against inferred type `T f f a'<br> In the expression: blah x<br> In the definition of `wrapper': wrapper x = blah x<br><br>Maybe it is a problem with ambiguous types, namely "f" appears only in applications of "T". But that is not the case, there is a "naked" f appearing as the argument of "T f". But perhaps the type checker does not want to unify those two f's precisely because they are the arguments of "T f".<br>
<br>I have tried to encode the above program using FunDeps, because this procedure helps me understand type errors. But in this case I get no type error!<br><br>> class A' (f :: * -> *) (g :: (* -> *) -> * -> *) | f -> g where<br>
<br>> class Blah' f a where<br>> blah' :: A' f g => a -> g f a<br><br>> wrapper' :: forall a f g . (Blah' f a,A' f g) => a -> g f a<br>> wrapper' x = blah' x<br><br>
So my question is whether my encoding is correct. And if it is, why isn't the type families version working?<br><br>Thanks!<br><br>Alexey<br><br>