[Haskell] Re: indirectly recursive dictionaries

oleg at okmij.org oleg at okmij.org
Tue Mar 17 04:59:41 EDT 2009

Ralf wrote:
> class C1 x
>  where
>  m1 :: x -> ()
>  m1 = const undefined

> instance (C1 x, C1 y) => C1 (x,y)
> instance C1 Bool
> instance (C2 x y, C1 (y,Bool)) => C1 x

> class C2 x y | x -> y
> instance C2 Int Int

> bar :: ()
> bar = m1 (1::Int)

I believe it works very well (meaning bar typechecks and even runs)
if we either add an instance 
	instance C1 Int
or change the instance of C2 to
	instance C2 Int Bool
Otherwise, the problem really has no solution, and looping is an
indication. I used GHC 6.8.3....

More information about the Haskell mailing list