Haskell's type for Pairs

ghci, haskell, types

Solution

That's because `Num` is not a type; it is a typeclass, and `Num t => someType` means that `t` is some arbitrary type that is an instance of the `Num` typeclass. To borrow some Java/C# terminology, you can think of `Num` as an interface, and `Num t => t` is a generic type with the constraint that `t` must implement the `Num` interface.

In general, you find the typeclass constraints on the left side of the `=>` arrow, and the type body on the right side. We could have multiple class constraints, for example `(Num a, Num b) => (a, b)`, which would denote the type of a tuple of two arbitrary numeric types. We can also have zero class constraints, in which case the `=>` is omitted.

In Haskell the numeric literals can represent any type that is an instance of `Num`. The literal `4` could denote a float or an integer, or (if you define some more exotic instances) even a function.

Problem

I'm trying to understand Haskell's type system. And I came along the following: ``` *Main> :t ("Hello", 4) ("Hello", 4) :: Num t => ([Char], t) *Main> :t ("Hello", 'a') ("Hello", 'a') :: ([Char], Char) *Main> :t ("Hello", True) ("Hello", True) :: ([Char], Bool) ``` Why is the type for `("Hello", 4)` not denoted like the others. I would have expected it to be `("Hello", 4) :: ([Char], Num)` I already saw the `=>` before. What I am wondering, is why does it make this difference?

Original source