
12 Nov
2009
12 Nov
'09
11:40 a.m.
This is just a theory, but in my (limited) experience, GHCi is willing to guess at the type of values, where at functions (explicitly or implicitly typed) it can't guess. In your original function, it multiplied a number (Num a) => a by an Int, therefor it must be Int -> Int (because you can't multiply a Double by an Int, don't be crazy. In the new function, though, it can infer the type of the 2, and therefor it can infer it to whatever numerical type you send it. I've run into this problem a few times, but for whatever reason I can't get myself to fall into any of the usual ways I walk blindly into these sorts of problems this time.