instance heads (was Re: DData modules)

Ross Paterson ross at
Fri Jan 14 11:15:38 EST 2005

On Thu, Jan 13, 2005 at 02:56:31PM +0000, Ross Paterson wrote:
> On Thu, Jan 13, 2005 at 02:13:08PM +0000, Malcolm Wallace wrote:
> > In what sense is
> >     instance Monoid (a -> a)
> > not Haskell'98?  It looks perfectly OK to me.  Is it because the two
> > type variable arguments to (->) are the same?
> Yes -- the Report even makes an example of instance C (a,a).
> But it seems that nhc98 implements this extension.

Nhc98 doesn't really implement it.  Try

	class C a where twist :: a -> a

	instance C (a,a) where twist (x,y) = (y,x)

	main = print (twist ('a',True))

which is incorrectly accepted, causing runtime trouble.  Also, the other
two examples in that section of the Report cause compile-time crashes:

	instance C (Int,a)
	instance C [[a]]

More information about the Libraries mailing list