[Haskell-cafe] Mutually recursive modules and google protocol-buffers

Chris Kuklewicz haskell at list.mightyreason.com
Wed Jul 16 06:01:59 EDT 2008

Thanks Roberto!

Roberto Zunino wrote:
> Chris Kuklewicz wrote:
>> There is no way to create a "A.hs-boot" file that has all of
>>   (1) Allows A.hs-boot to be compiled without compiling B.hs first
>>   (2) Allows B.hs (with a {-# SOURCE #-} pragma) to be compiled after 
>> A.hs-boot
>>   (3) Allows A.hs to compiled after A.hs-boot with a consistent interface
> I thought the following A.hs-boot would suffice:
> module A(A) where
> data A
> There's no need to provide the data constructors for type A. Does this 
> violate any of the goals above?
> Regards,
> Zun.

I tried that experiment.  The failure is complicated, and triggers be a ghc bug.

Hmmm... the bug for

> module A(A) where
> data A
>   deriving Show

using "ghc -c -XGeneralizedNewtypeDeriving A.hs-boot" is

> A.hs-boot:2:0:ghc-6.8.3: panic! (the 'impossible' happened)
>   (GHC version 6.8.3 for powerpc-apple-darwin):
> 	newTyConEtadRhs main:A.A{tc r5z}
> Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Is this a known bug?

But now I see that

> module A(A(..)) where
> import B(B)
> data A = A B | End
>   deriving Show

does work.  And avoids the bug!


More information about the Glasgow-haskell-users mailing list