

I'm vaguely aware of this stuff but have never actually had to use it, so I won't add any more so I don't get anything wrong. They need to be kept separate at the kind level so that ordinary type variables of kind * can't be instantiated with these unlifted/unboxed types (which would allow you to pass these types that need special handling to generic code that doesn't know to provide the special handling). There are also kinds used for unboxed/unlifted types, which must not be ever mixed with "normal" Haskell types because they have a different memory layout they can't contain thunks to implement lazy evaluation, so the runtime has to know never to try to "enter" them as a code pointer, or look for additional header bits, etc. ( Exactly the same way the way DataKinds actually works is that it lets you use a data declaration as normal and then you can use the resulting type constructor at either the type or the kind level) The advantage is now we can use all of the language features for manipulating type-level entities to manipulate constraints (including PolyKinds!).ĭataKinds adds the ability to create new user-defined kinds containing new type-level things, in exactly the same way that in vanilla Haskell we can create new user-defined types containing new term-level things. Classes like Eq become type constructors with kind * -> Constraint you apply it to a type like Eq Bool to produce a Constraint. Rather than the stuff left of the => being special purpose syntax fairly disconnected from the rest of the language, now what is acceptable there is anything with kind Constraint. (* -> k) -> k.ĬonstraintKinds makes constraints (the stuff to the left of the => in type signatures, like Eq a) become ordinary type-level entities in a new kind: Constraint. PolyKinds adds kind variables that work exactly the same way type variables work. There are several language extensions that add more features to the kind language. data ThreeStars a b = Cons a b makes a type constructor with kind * -> * -> *, while data AlsoThreeStars f = AlsoCons (f Integer) makes a type constructor with kind (* -> *) -> *. For example * -> * -> * is the kind of things that take two type arguments to produce a type, but (* -> *) -> * is the kind of things that take a single argumemt to produce a type where that argument itself must be a thing that takes a type argument to produce a type. It's not just the number of * or -> that matter, but how they are nested. The most basic form of the kind language contains only * (or Type in more modern Haskell I suspect we'll eventually move away from *) and ->.īut there are more things you can build with that language than you can express by just "counting the number of *s".
