[Haskell-cafe] Functional dependencies with Type Classes
Henning Günther
der_eq at freenet.de
Thu Mar 27 21:12:28 EDT 2008
Hi,
suppose there are two (identical) classes:
> class Res a b | a -> b where
> getRes :: a -> b
and
> class Res2 t where
> type Member t
> getRes2 :: t -> Member t
It is easy to automatically make every instance of Res2 an instance of
res:
> instance Res2 a => Res a (Member a) where
> getRes x = getRes2 x
However, declaring every instance of Res an instance of Res2 seems
impossible, as the following doesn't compile
> instance Res a b => Res2 a where
> type Member a = b
> getRes2 x = getRes x
Question is: How to do this? The reason I need it is because I use a
library which uses functional dependencies, but my classes shall be type
families.
Regards,
Henning
More information about the Haskell-Cafe
mailing list