Difference between C# interface and Haskell Type Class

Viewed 1281

I know that there is a similar question here, but I would like to see an example, which clearly shows, what you can not do with interface and can with Type Class

For comparison I'll give you an example code:

class Eq a where 
    (==) :: a -> a -> Bool
instance Eq Integer where 
    x == y  =  x `integerEq` y

C# code:

interface Eq<T> { bool Equal(T elem); }
public class Integer : Eq<int> 
{
     public bool Equal(int elem) 
     {
         return _elem == elem;
     }
}

Correct my example, if not correctly understood

4 Answers
Related