
Hello Maurício, Monday, November 17, 2008, 12:32:11 AM, you wrote:
class MyClass r where function :: r -> s
this tells that f may return value of any type requested at the call site, i.e. one can write main = do print (f (Mydata 1) :: String) print (f (Mydata 1) :: [Bool]) print (f (Mydata 1) :: Either Double Float)
instance MyClass (MyData v) where function (MyData a) = a
this definition can return value of only one type, so it can't serve all the calls i mentioned above
GHC says that the type of the result of 'function' is both determined by the "rigid type" from MyClass and the "rigid type" from MyData. But why can't both be the same?
are you OOPer? :) ps: GHC error messages should be fired :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com