Announcing Haskell protocol-buffers 1.4.0 (the smashing recursive edition)

Chris Kuklewicz haskell at list.mightyreason.com
Fri Jan 9 18:24:14 EST 2009


Hello,

   What is protocol-buffers?
     Google's "..language-neutral, platform-neutral, extensible way of 
serializing structured data for use in communications protocols, data storage, 
and more."
     http://code.google.com/apis/protocolbuffers/docs/overview.html
   What is Haskell protocol-buffers?
     This provides a program 'hprotoc' which compiles a ".proto" file defining 
messages to Haskell modules, and the protocol-buffers API to access them and 
convert back and forth to the binary wire protocol, and 
protocol-buffers-descriptors which are messages which describe ".proto" files 
and allow for runtime reflection of annotated message definitions.

   The big addition to this version (which is 1.4.0) over the previous version 
(which was 1.2.0) is for when modules are in a dependency loop.  The most common 
reason this happens is whenever a message is extended in the same proto file but 
outside of the message itself (e.g. at the top level).  This was salved in 
previous versions by telling the user to create boilerplate header files (a 
.hs-boot file) and add a few {-# SOURCE #-} pragmas.  This was primitive, and 
could not cover all the corner cases.

   Those days are gone.

   The new version of hprotoc uses the cutting edge version of haskell-src-exts 
(4.8.0) to generate not only the Haskell modules but also the hs-boot files and 
{-# SOURCE #-} pragmas!  This is truly a glorious way to start the New Year.

   But wait, there is more!  If a more than two messages define extensions of 
each other in a strongly connected dependency graph then the hs-boot files are 
not enough.  For these strange cases hprotoc will now generate modules ending 
with 'Key.hs that separately define the extensions.  You do not need to lift a 
finger, you never need to import these modules yourself, this all exists behind 
the scenes.  Also, hprotoc goes way out its way to reduce the number of .hs-boot 
and 'Key.hs files, and it uses only a minimal set of {-# SOURCE #-} pragmas.  It 
is so painless that if I did not put this into this announcement you might not 
even know.

   Now all generated should compile with no changes or additions.
   Of course, hprotoc still generates nothing for services and methods.

Where to get the new shiny packages? hackage:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/protocol-buffers

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/protocol-buffers-descriptor

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hprotoc

And you will need haskell-src-exts, version 0.4.8, by Niklas Broberg:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-exts-0.4.8

(past version do not work and future versions will probably change enough to 
break compilation of hprotoc)

Happy New Year,
   Chris Kuklewicz


More information about the Libraries mailing list