July 2023
Intermediate to advanced
670 pages
17h 13m
English
So far we’ve looked at types that represent a specific sort of value like an Int or a String. A value with a single type like this is called monomorphic. Monomorphic functions are great when you know exactly what kind of values you’ll be working with, but in many cases they’re unnecessarily restrictive. You can get around these restrictions and write more general functions by using polymorphism. In this section, you’ll learn about parametric polymorphism, which is the most common sort of polymorphism that you’ll encounter while writing Haskell. Later on in this book, you’ll be introduced to another kind of polymorphism called ad hoc polymorphism.
To understand how polymorphism works and how it can help us ...