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

Get Haskell Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.