subtle dissimilarity between fromInteger and fromIntegral

Hi, Can someone explain the subtle dissimilarity between fromInteger and fromIntegral? Thanks, Hong

fromInteger takes an integer to any instance of the Num class. The num class provides this function, because (at least in theory) any Integer "is" (in some sense) an element of a Num instancing class. fromIntegral has type `(Integral a, Num b) => a -> b` which means it takes any _integral) type (on that supports div and mod, and a function "toInteger" which takes an integral to an integer) to a num type. I imagine that "fromIntegral" is probably implemented fromIntegral = fromInteger . toInteger HTH /Joe On Sep 30, 2009, at 7:41 PM, Hong Yang wrote:
Hi,
Can someone explain the subtle dissimilarity between fromInteger and fromIntegral?
Thanks,
Hong _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (2)
-
Hong Yang
-
Joe Fredette