Interface-Vererbung

class Eq a where
    equals :: a -> a -> Bool -- sinngemäß

data Foo = ...
instance Eq Foo where ...

class Eq a => Ord a where
    compare :: a -> a -> Ordering

instance Eq Foo where ...

Beachte:

Typ: Haskell: (data) $ \approx$ Java: (class)
Schnittstelle: Haskell: (class) $ \approx$ Java: (interface)



Johannes Waldmann 2005-01-28