Hello! When I apply hugs to the following program: import Char (ord) class Conv a b | a -> b where conv:: a -> b instance Conv Char Int where conv = ord instance (Conv a b, Conv b c) => Conv a c where conv = conv . conv Hugs reports: ERROR "fdep.hs" (line 4): Instances are not consistent with dependencies *** This instance : Conv a b *** Conflicts with : Conv Char Int *** For class : Conv a b *** Under dependency : a -> b But why? Regards, Anton Moscal
Anton Moscal wrote:
Hello!
When I apply hugs to the following program:
import Char (ord) class Conv a b | a -> b where conv:: a -> b instance Conv Char Int where conv = ord instance (Conv a b, Conv b c) => Conv a c where conv = conv . conv
Hugs reports:
ERROR "fdep.hs" (line 4): Instances are not consistent with dependencies *** This instance : Conv a b *** Conflicts with : Conv Char Int *** For class : Conv a b *** Under dependency : a -> b
But why?
Because they aren't. Assume you have
instance Char Int and also instance Int Float According to your second instance declaration you now also have instance Char Float But the functional dependency states that the first parameter uniquely determines the second and now there are two conflicting instances for Char.
-- Lennart
participants (2)
-
Anton Moscal -
Lennart Augustsson