© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
A. Serrano MenaPractical Haskellhttps://doi.org/10.1007/978-1-4842-8581-7_4

4. Using Containers and Type Classes

Alejandro Serrano Mena1  
(1)
Utrecht, The Netherlands
 

You have seen how parametric polymorphism and higher-order functions help in the process of abstraction. In this chapter, I’ll introduce a new kind of polymorphism that sits in between parametric and the absence of polymorphism: ad hoc polymorphism. Using this feature, you can express that certain types exhibit a common behavior. Incidentally, you will also learn how Haskell makes it possible to use addition, (+), on different numeric types like Integer and Float while maintaining a strong type ...

Get Practical Haskell: A Real-World Guide to Functional Programming 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.