I’m proud to announce that I’m nearing completion on a major patch to GHC, merging types and kinds. This patch has been in development since late 2012 (!), with many interruptions in the meantime. But I really do think it will make it for 7.12, due out early 2016. This post is meant to generate discussion in the community about the proposed changes and to get feedback about any user-facing aspects which might be of interest.

## Motivation

The real motivation for writing this is that it’s a key step toward dependent types, as described in the paper laying out the theory that underlies this patch. But other motivation is close to hand as well. This patch fixes GHC bug #7961, which concerns promotion of GADTs – after this patch is merged, *all* types can be used as kinds, because kinds are the same as types! This patch also contributes toward the solution of the problems outlined in the wiki page for the concurrent upgrade to Typeable, itself part of the Distributed Haskell plan.

## Examples

Below are some fun examples that compile with my patch. As usual, this page is a literate Haskell file, and these examples really do compile! (I haven’t yet implemented checking for the proposed extension `StarInStar`

, which this will require in the end.)

```
> {-# LANGUAGE DataKinds, PolyKinds, GADTs, TypeOperators, TypeFamilies #-}
> {-# OPTIONS_GHC -fwarn-unticked-promoted-constructors #-}
>
> -- a Proxy type with an explicit kind
> data Proxy k (a :: k) = P
> prox :: Proxy * Bool
> prox = P
>
> prox2 :: Proxy Bool 'True
> prox2 = P
>
> -- implicit kinds still work
> data A
> data B :: A -> *
> data C :: B a -> *
> data D :: C b -> *
> data E :: D c -> *
> -- note that E :: forall (a :: A) (b :: B a) (c :: C b). D c -> *
>
> -- a kind-indexed GADT
> data TypeRep (a :: k) where
> TInt :: TypeRep Int
> TMaybe :: TypeRep Maybe
> TApp :: TypeRep a -> TypeRep b -> TypeRep (a b)
>
> zero :: TypeRep a -> a
> zero TInt = 0
> zero (TApp TMaybe _) = Nothing
>
> data Nat = Zero | Succ Nat
> type family a + b where
> 'Zero + b = b
> ('Succ a) + b = 'Succ (a + b)
>
> data Vec :: * -> Nat -> * where
> Nil :: Vec a 'Zero
> (:>) :: a -> Vec a n -> Vec a ('Succ n)
> infixr 5 :>
>
> -- promoted GADT, and using + as a "kind family":
> type family (x :: Vec a n) ++ (y :: Vec a m) :: Vec a (n + m) where
> 'Nil ++ y = y
> (h ':> t) ++ y = h ':> (t ++ y)
>
> -- datatype that mentions *
> data U = Star *
> | Bool Bool
>
> -- kind synonym
> type Monadish = * -> *
> class MonadTrans (t :: Monadish -> Monadish) where
> lift :: Monad m => m a -> t m a
> data Free :: Monadish where
> Return :: a -> Free a
> Bind :: Free a -> (a -> Free b) -> Free b
>
> -- yes, * really does have type *.
> type Star = (* :: (* :: (* :: *)))
```

## Details

More details are in the wiki page for this redesign. As stated above, I’d love your feedback on all of this!