[Haskell-cafe] Question on kind inference

Claus Reinke claus.reinke at talk21.com
Sun May 31 05:44:02 EDT 2009

> -----------------------------------------------
> class A a where
>  foo :: a b
> class B a
> class (A a, B a) => C a
> -----------------------------------------------
> GHC compiles it without errors, but Hugs rejects it: "Illegal type in
> class constraint".

The error message is horribly uninformative.

> What is the correct behavior, and which part of the haskell 98 report
> explains this?

4.6 Kind Inference, combined with 4.5(.1) dependency analysis.

My interpretation: 'A' and 'B' are not in the same dependency group,
so 'a's kind in 'B' defaults to '*', so 'C' is ill-kinded. Try moving 'B'
into a separate module to get the same effect in GHC (which, in the
single-module case, uses 'A' and 'C' to determine the kind of 'B's 'a').


More information about the Haskell-Cafe mailing list