no non-typevariable in instance declarations

José Romildo Malaquias
Wed, 15 Nov 2000 02:52:52 -0200

On Tue, Nov 14, 2000 at 07:41:21PM +0000, Marcin 'Qrczak' Kowalczyk wrote:
> Tue, 14 Nov 2000 16:17:48 -0200, José Romildo Malaquias <> pisze:
> > But this is not relevant to my question. Removing the instance
> > declaration
> > 
> >   instance C Integer where
> >       ty _ = "Integer"
> > 
> > from the program (so that there is no instance overlapping now)
> > does not help.
> In this case your instance would be the only one possible (any other
> would overlap) and it could be equally well written as a plain function.

Any instance for a no-Num type will not overlap:

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

  instance C Char where
    ty _ = "CHAR"

and the overloaded function cannot be written as
a plain function.

> Actually Haskell 98 has more severe restriction than non-overlapping
> instances. The instance head must be a type constructor applied to
> as many distinct type variables as needed to let the kinds match.
> "instance Foo [Int]" is as non-standard as "instance Foo a".

I am not understand the restriction well. I verified that
both Hugs and GHC, when using extensions, accepts
"instance C [Int]", but only Hugs accepts 
"instance (Num a) => C a".

Where is this issue presented in a simple way easily
understandable by regular Haskell programmers? Any pointers?

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