Skip to main content

Using Containers and Type Classes

  • Chapter
  • First Online:
  • 3135 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. 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

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.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

Learn about institutional subscriptions

Notes

  1. 1.

    You can check the full Package Versioning Policy, and look for updates, at www.haskell.org/haskellwiki/Package_versioning_policy .

  2. 2.

    At the time of this writing, support for sandboxes through plain Cabal is being implemented.

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

Authors

Rights and permissions

Reprints 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

Publish with us

Policies and ethics