When building this example with GHC 6.12.4, it fails with a complaint about the bogus type constraints in the declaration of fromHsk:

test.hs:3:0:
All of the type variables in the constraint `C a'
are already in scope (at least one must be universally quantified here)
(Use -XFlexibleContexts to lift this restriction)
When checking the class method: fromHsk :: (C a) => a -> Int
In the class declaration for `C'

After removing these unneeded constraint (i.e. changing the declaration of fromHsk to fromHsk :: a -> Int, the snippet above builds even with GHC 7.0.4 and optimizations.

Change History (3)

Interesting example! This program should diverge, of course, but it should not do so at runtime. Yet it turns out to be a disguised case of GHC's well-known compile-time divergence bug (User manual 12.2.1, bullet 3).

Here is the desugaring of the program after dictionaries have become explicit:

It's a classic example of the Russell-paradox loop. The manual claims this "never happens in practice" and I guess this bug report is a counter-example! However, it's not easy to fix this particular loop; and as you found, it's not a program you want to write anyway.