[Haskell-beginners] Type of function with constant pattern

j.romildo at gmail.com j.romildo at gmail.com
Tue Apr 10 21:57:38 CEST 2012


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.


More information about the Beginners mailing list