
On Mon, May 12, 2014 at 11:44 AM, Venu Chakravorty
Prelude> :t (+) (+) :: (Num a) => a -> a -> a
What I understand from the above is that "+" is a function that takes two args which are types of anything that IS-AN instance of "Num" (Int, Integer, Float, Double) and returns an instance of "Num".
Not exactly. It says that, given some type a that is an instance of Num, it will add two values of that type and produce a new value of that same type. You cannot mix and match types; it always works on some specific type, although those types may change between uses of (+). This is somewhat hidden by the way numeric literals are handled: a literal without a decimal point is handled as if you had wrapped it in fromIntegral, and one with a decimal point is handled as if you had wrapped it in fromRational. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net