class Num a where ...
As a side note, according to some of my sources (slides), it should actually be
class Eq a => Num a where ...
but I cannot find this in the Prelude.
Now, I am interested in the
Real type class
class (Num a, Ord a) => Real a where -- the rational equivalent of its real argument with full precision toRational :: a -> Rational
I guess that
Real refers to the fact that types that are instances of
Real are not complex. But my understanding of a
Real number from Mathematics is that it can be Rational and Irrational, so there is no equivalent of
toRational for all of them. Of course, irrational numbers can't be used in computers anyways...
Yes, the name
Real is a rather misleading name for the class of types that can be converted to a rational.
Indeed, we have instances like
Real CBool which can be very surprising.
The standard numeric classes are generally regarded as being a bit weird, both in their names and in their overall design.