Generische Instanzen (I)

class Eq a where
    (==) :: a -> a -> Bool
Vergleichen von Listen (elementweise)

wenn a in Eq, dann [a] in Eq:

instance Eq a => Eq [a] where
    []       == []        
        =  True
    (x : xs) == (y : ys)  
        =  (x == y) && ( xs == ys )
    _        == _         
        =  False



Johannes Waldmann 2011-01-18