Abstract
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. And incidentally, you will learn how Haskell makes it possible to use addition, (+), on different numeric types while maintaining a strong type system.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsNotes
- 1.
You can check the full Package Versioning Policy, and look for updates, at www.haskell.org/haskellwiki/Package_versioning_policy .
- 2.
At the time of this writing, support for sandboxes through plain Cabal is being implemented.
- 3.
The Haskell Platform is quite complete, so it also includes a type for complex numbers, which you can find in the Data.Complex module. This definition will be merely illustrative.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2014 Alejandro Serrano Mena
About this chapter
Cite this chapter
Mena, A.S. (2014). Using Containers and Type Classes. In: Beginning Haskell. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4302-6251-0_4
Download citation
DOI: https://doi.org/10.1007/978-1-4302-6251-0_4
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4302-6250-3
Online ISBN: 978-1-4302-6251-0
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books