-- here's the class we are defining class Foo a where equ :: a -> a -> Bool -- here are two data types who are members -- of the class data Bar = Barc Integer data Baz = Bazc Double -- helper methods ubarc (Barc a) = a ubazc (Bazc a) = a -- make Bar an instance of Foo instance Foo Bar where equ a b = (ubarc a) == (ubarc b) -- make Baz an instance of Foo instance Foo Baz where equ a b = (ubazc a) == (ubazc b) -- create some data t1 = Barc 3 t2 = Barc 4 t3 = Bazc 1.0 t4 = Bazc 1.0 main = do putStrLn(show(t1 `equ` t2)) putStrLn(show(t3 `equ` t4))