Type-level programming
Type families bring functions to the type-level. Polymorphic kinds bring polymorphism to the kind-level. Type promotion bring datatypes and type-safety to the kind-level.
Two major problems of the Haskell kind system are solved by these extensions:
- The kind system is too restrictive (because it lacks polymorphism)
- Solution: Provide polymorphism on the kind level
(PolyKinds)
- Solution: Provide polymorphism on the kind level
- The kind system is too permissive (kinds are too vague)
- Solution: Promote datatypes to kinds to simulate a type-system on the kind-level
(DataKinds)
- Solution: Promote datatypes to kinds to simulate a type-system on the kind-level
Haskell98 already carried the seed for type-level programming by including multiparameter type-classes. Since then, the Haskell kind-system has been enriched with functional dependencies, GADTs, type families, ...
Get Haskell Design Patterns now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.