
Ertugrul Soeylemez
[...] If that's all you need to know, you can generalize the function
foo :: Integer -> Integer -> Integer foo a b = a*a + b*b
to the following:
foo :: Integral i => i -> i -> i foo a b = a*a + b*b
Now 'foo' is defined for every type, which is an instance of the class Integral. Being an instance of that class precisely means that (+), (*) and some other functions are defined for the particular type. Since this is all you need to know for 'foo', there is no reason to restrict it to Integer.
Sorry, I actually meant the Num class, not the Integer class, but the example is still valid, because any Integral type is also a Num type. So here is a more general 'foo': foo :: Num a => a -> a -> a foo a b = a*a + b*b Greets, Ertugrul. -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/