Existentially quantified type variables (or simply “existential types” for short) are useful tools for data abstraction. In combination with type classes, they allow you to write code in an “object oriented” style that is similar to the use of interfaces in Java or abstract base classes in C++.
Mercury supports existential type quantifiers on predicate and function declarations, and in data type definitions. You can put type class constraints on existentially quantified type variables.
|• Existentially typed predicates and functions:|
|• Existential class constraints:|
|• Existentially typed data types:|
|• Some idioms using existentially quantified types:|