
Hi Fredrik, Temaran wrote:
data Dar = Dar String String deriving (Show, Eq)
class Bar a where foo :: a -> Int
instance Bar Dar where foo(Dar n c) = length c
but it keeps generating the same error;
ERROR "./Bar.hs":16 - Inferred type is not general enough *** Expression : foo *** Expected type : a -> Int *** Inferred type : Dar -> Int
You're missing indentation. Instead of declaring foo as a member of the typeclass, your code says it's a top-level function fully-polymorphic in the first parameter. That's why defining it later as foo (Dar ...) gives the error message it does. -- View this message in context: http://www.nabble.com/Essentials-about-type-classes--tp25393728p25405022.htm... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.