Specifying Kinds of Types

John Hughes rjmh@cs.chalmers.se
Fri, 8 Feb 2002 13:22:09 +0100 (MET)

	Ashley Yakeley wrote:

	I'd like to be able to declare the kinds of new types and synonyms, 
	because sometimes Haskell can't infer them. For instance:

	    data CMap0 p q = MkCMap0;

	Without evidence, Haskell assumes that p and q have kind '*' (as per sec. 
	4.6), and therefore CMap0 has kind '* -> * -> *'. Actually, I wanted p 
	and q to both have kind '* -> *', giving CMap0 kind '(* -> *) -> (* -> *) 
	-> *'.

I'll second that! I've had to use the likes of

     data CMap0 p q = MkCMap0 | forall a. Unused (p (q a))

in the past, but this is ugly and doesn't work for type or newtype. And of
course, next time you have to call the constructor Unused2 or UnusedCMap0 or
whatever to avoid a name clash...

	It's not currently possible to specify kinds, is it? Actually I think 
	polymorphic kinds would be nice, but I can't say I desperately need them. 

The nicest thing about polymorphic kinds would be that we wouldn't NEED to
specify them: kind inference would produce the principal kind, and you can't
do better than that. I assume it will be a while before we start wanting
rank-2 polykindism!

Compilers already do kind inference, and presumably explicitly set
uninstantiated kind variables to * at some stage. Maybe generalising them
instead would be a simple modification and language extension that would solve
this kind of problem.

John Hughes