Hello, I am reading a book to learn Haskell and I implemented some basic functions.

Today I wrote four different functions checking two numbers for equality. Three of them need numeric types, and one function can take every basic type.

Here they are:

` equal_1 :: Integral a => (a -> (a -> Bool))`

`equal_1 x y = x == y`

`equal_2 :: Eq a => (a -> (a -> Bool))`

`equal_2 x y = x == y`

`equal_3 :: (Int -> (Int -> Bool))`

`equal_3 x y = x == y`

And one functions which is wrong (tested with ghci):

`equal_4 :: Num a => (a -> (a -> Bool))`

`equal_4 x y = x == y`

Why is `equal_4`

wrong? There I use a class constraint. In `equal_1`

and `equal_2`

I use class constraints too and it works. The first function is limited to Integral types, the second function can take each basic type and function 3 is limited to Int.

And which type signature is the most useful? Does it depend on certain circumstances?

And should I use the class Eq in a type signature?

Thanks!