[Haskell-cafe] Funct dependency conflict when using types
Frank
frank at geoinfo.tuwien.ac.at
Sun Apr 30 05:53:23 EDT 2006
I have observed the error message (ghci 6.4)
Functional dependencies conflict between instance declarations:
LocTest.hs:16:0: instance B S Bool
LocTest.hs:22:0: instance (F f, B a b) => B (f a) (f b)
when I changed in an instance from a simple type to a type with a parameter
(i.e. from Int to (Int, Bool)).
The following minimal program demonstrates the problem:
an instance with type S (= T Float) conflicts with B (f a) (f b)
whereas the comparable instance with data R (= R Float) does not.
Is this intentional? How can it be avoided?
Help is greatly appreciated!
Andrew
----------------------------------------
class F f where
m2 :: (a -> b -> c) -> f a -> f b -> f c --zipWith
class B a b | a -> b where
dist2 :: a -> a -> b
instance B S Bool where -- line 16
dist2 a d = True
instance B R Float where
dist2 a d = 1
instance (F f, B a b) => B (f a) (f b) where -- line 22
dist2 a b = m2 dist2 a b
data T f = T f
type S = T Float
data R = R Float
More information about the Haskell-Cafe
mailing list