[Haskell] Empty instance declaration

ajb at spamcop.net ajb at spamcop.net
Fri Dec 28 22:51:56 EST 2007


G'day all.

Quoting Isaac Dupree <isaacdupree at charter.net>:

> I know!  I said so!  My question is whether anyone has an example of
> doing either of those in mutually-recursive DEFAULT METHOD definitions?

class (Eq a) => StupidEqList a where
     eqList :: [a] -> [a] -> Bool
     neqList :: [a] -> [a] -> Bool

     eqList [] [] = True
     eqList (x:xs) (y:ys) = x == y && not (neqList xs ys)
     eqList _ _ = False

     neqList [] [] = False
     neqList (x:xs) (y:ys) = x /= y || not (eqList xs ys)
     neqList _ _ = True

Stupid, but not illegal.

Cheers,
Andrew Bromage


More information about the Haskell mailing list