no non-typevariable in instance declarations

José Romildo Malaquias
Tue, 14 Nov 2000 16:17:48 -0200

On Tue, Nov 14, 2000 at 05:02:30PM +0000, Malcolm Wallace wrote:
> > class C a where
> >     ty :: a -> String
> > instance (Num a) => C a where
> >     ty _ = "NUM"
> > instance C Integer where
> >     ty _ = "Integer"
> > Why GHC and NHC98 are more restrictive than Hugs?
> The instances for (Num a=> a) and Integer overlap, and are therefore
> forbidden by Haskell'98.

But this is not relevant to my question. Removing the instance

  instance C Integer where
      ty _ = "Integer"

from the program (so that there is no instance overlapping now)
does not help. Both GHC and NHC98 still complains with the
same diagnostics as before. They are not accepting the
instance declaration

  instance (Num a) => C a where
      ty _ = "NUM"

because there is no non-type-variable component in the
instantiated type "a" above.

Again, why they have this restrictions while Hugs has not?

> Hugs allows overlapping instances.

When given the option +o

> So does GHC with a special flag (-foverlapping-instances I think).


> nhc98 does not provide type-system extensions to Haskell'98.

Not exactly. NHC98 provides at least the following
extension to Haskell 98:
	* existentialy quantified type variables

(By the way, is there any plans to implement multiparameter type
classes and instance overlapping in NHC98?)


Prof. José Romildo Malaquias <>
Departamento de Computação
Universidade Federal de Ouro Preto