O'Reilly logo

The Haskell School of Expression by Paul Hudak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER TWELVE

Qualified Types

 

 

 

 

 

Recall that a polymorphic type such as (aa) is really shorthand for ∀(a)aa, which can be read “for all types a, functions mapping elements of type a to elements of type a.” Note the emphasis on for all.

In practice, however, there are times when we would prefer to limit a polymorphic type to a smaller number of possibilities. A good example is a function such as (+). It’s probably not a good idea to limit ( + ) to a single (that is, monomorphic) type such as IntegerIntegerInteger, because there are other kinds of numbers – such as floating-point and complex numbers – that we would like to perform addition on. Nor is it a very good idea to have a different addition function for each type of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required