November 2015
Intermediate to advanced
166 pages
3h 14m
English
Type families gives us functions at the type-level (through type functions). Analogously, the Polykinds language extension gives us polymorphism at the type-level.
Kind polymorphism (Giving Haskell a Promotion, by Yorgey et al in 2012) allows us to describe more generic data and functions. For example, when designing a type-class, the need may arise to cater for various kind-orders. Consider the multiple Typeable classes for multiple arities as an example:
class Typeable (a :: * ) where typeOf :: a -> TypeRep class Typeable1 (a :: * -> *) where typeOf1 :: forall b. a b -> TypeRep
The same goes for the Generic type-class we encountered earlier: we need to define different type-classes for different kind arities.
To explore kind polymorphism, ...
Read now
Unlock full access