[Haskell-beginners] Sections in Class definition

John Smith voldermort at hotmail.com
Mon Aug 23 03:28:38 EDT 2010


I tried to reproduce the definition of Eq with

class Eq a where
     (==), (/=) :: a -> a -> Bool

     (/=) = not (==)
     (==) = not (/=)

and got

     Couldn't match expected type `Bool'
            against inferred type `a1 -> a1 -> Bool'
     In the first argument of `not', namely `(==)'
     In the expression: not (==)
     In the definition of `/=': /= = not (==)

     Couldn't match expected type `Bool'
            against inferred type `a1 -> a1 -> Bool'
     In the first argument of `not', namely `(/=)'
     In the expression: not (/=)
     In the definition of `==': == = not (/=)

What have I done wrong? Is it not possible to define Eq in point-free style?



More information about the Beginners mailing list