I have something to add, in case you couldn't gather something from leftaroundabout's thorough answer.
Everything to the left of =>
in a type signature is a constraint. Read the type like this:
compareWithHundred :: (Num a, Ord a) => a -> Ordering
^^^^^^^^^^^^^^ ^ ^^^^^^^^
constraints | |
argument type |
result type
So you only pass one argument to the function because there is only one argument in the type signature, a
. a
is a type variable, and can be replaced with any type as long as that type satisfies the constraints.
The Num a
says that whatever you replace a
with has to be numeric (so it can be Int
, Integer
, Double
, ...), and the Ord a
says that it has to be comparable. leftroundabout's answer goes into more detail about why you need both, I just wanted to make sure you knew how to read the signature.
So it's perfectly legal in one sense to say compareWithHundred "foobar"
, the type checker says that that expression's type is Ordering
, but then it will fail later when it tries to check that there is a Num String
instance.
I hope this helps.