class parameters to existential datatypes

John Hughes rjmh@cs.chalmers.se
Thu, 6 Dec 2001 22:04:46 +0100 (MET)


	I would like to be able to write something like this:

	> data Foo c = forall a . c a => Foo a

	Unfortunately, this isn't allowed (apparently) because it's an illegal
	class assertion (or at least that's what ghc tells me).

	... 

	so I have two questions:

	  1) Is there any particular reason whey we can't do this (it would
	     break some type safety things or whatever)
	  2) Any ways to get around it?

	Thanks!

	 - Hal

Hmm. Interesting.

I wrote a paper a couple of years ago, on "Restricted Data Types", which
discusses among other things how to simulate abstraction over a class by
abstraction over the corresponding dictionary type. You might find the
technique useful. It's at

	  http://www.cs.chalmers.se/~rjmh/Papers/restricted-datatypes.ps

John Hughes