Declaring and working with Kinds in Haskell

144 Views Asked by At

I've been playing with Haskell's -XDataKinds feature quite a lot recently, and have found myself wanting to create a kind.

I'm not sure if my wishes can come true, but from Edward Kmett's constraints package, there seems to be a declared kind Constraint (with sort BOX), which says to be defined in GHC.Prim, but I couldn't find it.

Is there any way to declare a kind in Haskell or GHC, manually? This would probably need manual assertion that data types declared with data would be of the proper kind. My idea is something like the following:

data Foo :: BOX

data Bar a :: Foo where
  Bar :: a -> Bar a
1

There are 1 best solutions below

2
On BEST ANSWER

In current GHC (7.8 at time of writing), one cannot separate the declaration of a fresh kind from the declaration of its type-level inhabitants.