O'Reilly logo

Haskell Design Patterns by Ryan Lemmer

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

Abstracting datatypes

In this section, we will describe a series of patterns related to data abstraction. We start with existentially quantified types then progress to phantom types and end with GADTs. We'll see that these patterns fall within a spectrum of generality and power.

Universal quantification

Let's explore existential quantification from the perspective of its opposite, universal quantification.

All parametrically polymorphic functions, from Rank 1 to higher rank functions, are universally quantified. Similarly, parametrically polymorphic data­types are universally quantified. If the Haskell syntax for universally quantified functions and data­types were consistent, then we would have had to use the forall keyword in data­type signatures ...

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