I know that 2 is something of the type Integral, however what does
this
differ from Int? The same question goes for Fractional and
Floating, what
exactly is their commonality and what exactly is their difference?
Numeric literals are a special case. To make it possible to write
"2" and
mean it as an Int or an Integer (or any other numeric type), 2 is
defined
to *really* mean (fromIntegral 2). fromIntegral is a function that
takes an
Integral value (such as 2), and converts it to a type of your
choice, so
long as it's a member of the Num class.
Ahem. 2 is defined to really mean (fromInteger 2), not "fromIntegral".
And "fromInteger" takes an *Integer* value.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe