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

Chris Kuklewicz haskell at list.mightyreason.com
Tue Jul 15 07:21:16 EDT 2008


I have reached an impasse in designing a Haskell API for the google's
protocol-buffers data language / format. (
http://code.google.com/apis/protocolbuffers/docs/overview.html )

The messages in protobuf are defined in a namespace that nests in the usual
hierarchical OO style that Java encourages.

To avoid namespace conflicts, I made a hierarchy of modules.

But...this is a legal pair protobuf message definitions:

> // Test that mutual recursion works.
> message TestMutualRecursionA {
>   optional TestMutualRecursionB b = 1;
>   optional int32 content = 2;
> }
> 
> message TestMutualRecursionB {
>   optional TestMutualRecursionA a = 1;
>   optional int32 content = 2;
> }

And there is no way ghc can compile these in separate modules.

But the overlap of record accessors names "content" makes defining these
messages in a single module with a common namespace quite verbose.

Any opinions on the least worst way to design this?

-- 
Chris



More information about the Haskell-Cafe mailing list