Haskell: Does Num class "inherit" Eq class?

haskell

Solution

The Haskell report suggests that `Num` should be a subclass of `Eq` and `Show`, but if you look at the source for the `Num` class in ghc, then it is not.

This change appears to have been introduced in GHC 7.4.1

Problem

From Learn You a Haskell, I have: ``` lucky :: Integral a => a -> String lucky 7 = "lucky number seven!" lucky x = "try again" ``` but, when I do ``` lucky :: Num a => a -> String lucky 7 = "lucky number seven!" lucky x = "try again" ``` I get ``` Could not deduce (Eq a) arising from literal `7' ``` So, then I do ``` lucky :: (Eq a, Num a) => a -> String lucky 7 = "lucky number seven!" lucky x = "try again" ``` and, the compiler is happy. Doesn't the Num type class "inherit" the Eq class? Saying (Num a, Eq a) seems redundant. From the Haskell 98 report, where they have a great diagram (yeah, visuals!) of the Standard Classes it sure seems like it's "inherited." http://www.haskell.org/onlinereport/basic.html

Original source

Related problems