<A HREF="manual_contents.html"><img align=center src="contents.gif" ALT="Contents"></A> Up Previous Next

Detailed kind errors +k,-k


Haskell uses a system of kinds to ensure that type expressions are well-formed: for example, to make sure that each type constructor is applied to the appropriate number of arguments. For example, the following program:

 module Main where

 data Tree a  = Leaf a | Tree a :^: Tree a

 type Example = Tree Int Bool

will cause an error:

 ERROR "Main.hs" (line 3): Illegal type "Tree Int Bool" in

                           constructor application

The problem here is that Tree is a unary constructor of kind * -> *, but the definition of Example uses it as a binary constructor with at least two arguments, and hence expecting a kind of the form (* -> * -> k), for some kind k.

By default, Hugs reports problems like this with a simple message like the one shown above. However, if the +k option is selected, then the interpreter will print a more detailed version of the error message, including details about the kinds of the type expressions that are involved:


 ERROR "Main.hs" (line 3): Kind error in constructor application

 *** expression     : Tree Int Bool

 *** constructor    : Tree

 *** kind           : * -> *

 *** does not match : * -> a -> b



In addition, if the +k option is used, then Hugs will also include information about kinds in the information produced by the :info command:

 Prelude> :info Tree

 -- type constructor with kind * -> *

 data Tree a



 -- constructors:

 Leaf :: a -> Tree a

 (:^:) :: Tree a -> Tree a -> Tree a



 -- instances:

 instance Eval (Tree a)



 Prelude>