
Hi guys, We are having trouble with the following program that uses type families:
class Blah f a where blah :: a -> T f f a
class A f where type T f :: (* -> *) -> * -> *
the following function does not type:
wrapper :: forall a f . Blah f a => a -> T f f a wrapper x = blah x
GHC gives the error: Couldn't match expected type `T f1 f1 a' against inferred type `T f f a' In the expression: blah x In the definition of `wrapper': wrapper x = blah x 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". 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!
class A' (f :: * -> *) (g :: (* -> *) -> * -> *) | f -> g where
class Blah' f a where blah' :: A' f g => a -> g f a
wrapper' :: forall a f g . (Blah' f a,A' f g) => a -> g f a wrapper' x = blah' x
So my question is whether my encoding is correct. And if it is, why isn't the type families version working? Thanks! Alexey