[clean-list] About semantic restrictions on type classes.

Fabien Todescato f.todescato@larisys.fr
Thu, 23 Jan 2003 11:41:51 +0100


Dear Cleaners,

In §6.11 of the Clean Language Report 2.1, it is said that :

	A type instance of an overloaded type must be a  flat type , i.e. a
type of the form T a1...an where ai are type variables which are  all
different.

supposing I have the following :

class k x y :: x y -> y

The above-mentionned restriction prevents the definition of :

instance k x ( t x )

where t is some type constructor.

Now, if the class k is instead defined as follows :

class k x t y :: x ( t y ) -> t y

I can write :

instance k x t y.

That is, using type-constructor classes may provide in some cases a
workaround to the limitations imposed by the 'flat type' semantic
restriction above.

Now, there is certainly a good reason why that 'flat type' semantic
restriction does exist, a reason however that is currently beyond my reach.

Could anybody give a few explanations about that restriction ?

Sincerely yours, Fabien Todescato