Given a function like negate, it has the type signature:
negate :: Num a => a -> a
which I would describe as a being the type in the context of Num (correct me if you think I am wrong).
But I not fully sure how to describe something like last, which has the type signature:
last :: [a] -> a
My guess would be to say it isn't type-specific, and that it takes a list and produces a single value of the same type as the list. Is this the correct way to think about it?
First,
ais not the type in the context ofNum, but a type that has aNuminstance.Num a => a -> ais a constrained polymorphic type, while[a] -> ais an unconstrained polymorphic type, or just polymorphic type for short. In the unconstrained case,acan be any type; in the constrained case, it must be a type that obeys the given constraints.