
I believe that "f 0 = ..." is a guard and the guard is pattern matching on
the constructor. Despite the fact that you don't have an instance of "f _ =
....", the compiler needs an Eq instance to determine if it should run the
"f 0" version of the function.
Does that make sense? Hopefully someone with a better grasp of the topic
will fill in the details.
--Tim
On Tue, Apr 10, 2012 at 12:57 PM,
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?
As both are defined using a constant pattern, I expected none of them should require the type of the argument to be instance of Eq.
Romildo
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners