Type variables instead of concrete types
If you are new to Haskell you may think that type variables and polymorphism are fancy things that are rarely used. Maybe you are surprised that type variables and type class constraints can increase safety and readability also if you are eventually using only one concrete type.
Imagine the Prelude would contain the following functions:
maximum :: [Integer] -> Integer sum :: [Integer] -> Integer
Sure, the names are carefully chosen and thus you can guess what they do. But the signature is not as expressive as it could be. Indeed these functions are in the Prelude but with a more general signature.
maximum :: (Ord a) => [a] -> a sum :: (Num a) => [a] -> a
but the signatures show which aspects of integers are actually required.We realize that