I'm going through a haskell tutorial (Learn you a haskell for great good) and I was playing around with this code I wrote based of off one of the functions in the book.
reverseNum :: (Num a) => a -> a
reverseNum 123 = 321
reverseNum x = 0
and ghci tells me that it can't deduce (Eq a) from (Num a).
So I change the first line to this
reverseNum :: (Integral a) => a -> a
and it worked. This was strange because I thought to be a part of the Num typeclass you needed to also be apart of Eq.
I tried one more thing to satisfy me curiosity and changed the first 2 lines to this
reverseNum :: (Floating a) => a -> a
reverseNum 1.0 = 0.1
and it gave me the same error.
I know that you can fix this by doing something like reverseNum :: (Num a, Eq a) ...
but I want to know why Integral is the only one where Eq can be deduced.
Why is that?
P.S. I am really new to haskell so... be gentle :)