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

Henning Thielemann lemming at henning-thielemann.de
Tue Jul 15 10:54:34 EDT 2008

On Tue, 15 Jul 2008, Chris Kuklewicz wrote:

> Consider these 3 files:
> A.hs:
>> module A(A) where
>> import B(B)
>> data A = A B
> B.hs
>> module B(B) where
>> import A(A)
>> data B = B A
> Main.hs
>> module Main where
>> import A
>> import B
>> main = return ()

Sooner or later you want generalize your datatypes. Then you can define
    data A b = A b
   and you do not need to import B any longer. I do not know if this is a 
generally applicable approach, but it helped me in some cases.
  There is still a problem with mutually recursive classes. In the one case 
where I had this problem, I could solve it the opposite way, namely by 
turning one type variable into a concrete type, which could represent all 
values one could represent with the variable type.

More information about the Haskell-Cafe mailing list