Skip to main content

Using Containers and Type Classes

  • Chapter
  • First Online:
Book cover Practical Haskell
  • 2010 Accesses

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. 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 system.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 34.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    You can read the full Package Versioning Policy at pvp.haskell.org .

  2. 2.

    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

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Alejandro Serrano Mena

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Serrano Mena, A. (2019). Using Containers and Type Classes. In: Practical Haskell. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-4480-7_4

Download citation

Publish with us

Policies and ethics