On Tue, 10 Apr 2012 16:57:38 -0300 j.romildo@gmail.com wrote:
Hello.
Given the following function definitions
f 0 = True
g False = True
ghc infers the following types for the functions:
f :: (Eq a, Num a) => a -> Bool g :: Bool -> Bool
Why f has "Eq a" in the context in ts type, and g does not?
Bool is an instance of Eq, so there's no need to say that your (non-existent) type variable has that constraint. Using a numeric constants means you get a type variable with the Num constraint. Since Num doesn't imply Eq, that constraint is (as Tim pointed out) required so the guard can be checked. <mike -- Mike Meyer <mwm@mired.org> http://www.mired.org/ Independent Software developer/SCM consultant, email for more information. O< ascii ribbon campaign - stop html mail - www.asciiribbon.org