Working with Polymorphic Functions
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 ...
Get Effective Haskell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.