ANNOUNCE: protocol-buffers-0.2.9 for Haskell is ready

Simon Marlow marlowsd at
Tue Sep 23 15:22:18 EDT 2008

Chris Kuklewicz wrote:
> I am cross-posting this message to several lists.
> I had learned the trick before the documentation was updated.  It seems 
> I have used a very unreliable trick.  And the "use castToSTUArray" 
> suggested alternative is a really poor one since I am not using arrays 
> at all.

castSTUArray is the way GHC does it - the idea is to allocate a small 
array, store the Float/Double in it, cast the type of the array to 
Word32 or whatever, and then read out the contents.

It's more or less equivalent to the peek/poke solution, except that it 
doesn't need unsafePerformIO.

GHC's code is here: (look for floatToWord):


More information about the Libraries mailing list